Angadi (Tamil: அங்காடி. Meaning: Market, Shop) is a Ruby on Rails webapp to demo a custom built eCommerce site.
This application was generated with the rails_apps_composer gem provided by the RailsApps Project.
- Verify and fix local database username and password here: config/database.yml
- Run the following command on terminal from the project folder
$ bundle install
$ RAILS_ENV=development rake db:create db:setup
$ rails server
The website UI is built using bootstrap 3.
Admin page provides interface to edit products, categories, brands and campaigns. https://angadi-balaji.herokuapp.com/admin
- Category -> Sub-Category -> Sub-Sub-category is implemented via a tree-like structure with each record in
categories
table having aparent_id
that is anid
of the categories record itself. Querying all products belong to a particular node in the tree is implemented via psql recursive query.
def all_children
Category.find_by_sql(%(WITH RECURSIVE all_categories AS (
SELECT id, name, parent_id FROM categories
WHERE id = '#{id}'
UNION
SELECT cat.id, cat.name, cat.parent_id FROM categories cat
JOIN all_categories a
ON (a.id = cat.parent_id)
)
SELECT * FROM all_categories;))
end
- Full text search is done via Postgresql's
tsvector
andtsquery
datatypes.
def search_query(term)
ActiveRecord::Base.connection.execute(%(select id
from (select products.id as id,
to_tsvector(categories.name) ||
to_tsvector(products.name) ||
to_tsvector(brands.name) as document
from products
join categories on categories.id = products.category_id
join brands on brands.id = products.brand_id) search
where search.document @@ to_tsquery('#{term}')
order by ts_rank(search.document, to_tsquery('#{term}')) desc;))
end
- Editing products in Admin interface uses the best_in_place gem.
- Other notable gems used:
- rmagick for image compression
- will_paginate
- Create products, categories, brands, campaigns via Admin interface
- Rating and Reviews
- Discounts
- Multiple images for products
- Campaign pages
- Chain multiple searches together
- Custom UI (enhance the default bootstrap UI)
- Improve test coverage