Please create a ticket on github if you have issues. They will be addressed ASAP.
This is a Rails e-commerce platform. ROR Ecommerce is a Rails 8.1 application with the intent to allow developers to create an ecommerce solution easily. This solution includes an Admin for Purchase Orders, Product creation, Shipments, Fulfillment and creating Orders. There is a minimal customer facing shopping cart understanding that this will be customized. The cart allows you to track your customers' cart history and includes a double entry accounting system.
The project has Searchkick-powered product search (backed by Elasticsearch), Tailwind CSS for storefront styling, and Turbo + Stimulus via Import Maps for modern JavaScript. Currently the most complete Rails solution for your small business.
Please use Ruby 3.3.8 and enjoy Rails 8.1.
ROR Ecommerce is designed so that if you understand Rails you will understand ROR_ecommerce. There is nothing in this project besides what you might see in a normal Rails application. If you don't like something, you are free to just change it like you would in any other Rails app.
Contributors are welcome! We will always need help with UI, documentation, and code, so feel free to pitch in. To get started, simply fork this repo, make any changes (big or small), and create a pull request.
Take a look at The Demo. The login name is test@ror-e.com with a password => test123
NOTE: Given that everyone has admin rights to the demo it is frequently looking less than "beautiful".
Please feel free to ask/answer questions in our Google Group.
Install Ruby 3.3.8 using a version manager such as rbenv or RVM. If you already have 3.3.8 on your system you're good to go.
Copy the database.yml for your setup. For SQLite3, cp config/database.yml.sqlite3 config/database.yml. For MySQL, cp config/database.yml.mysql config/database.yml and update your username/password.
If you are using the mysql dmg file to install mysql you will need to edit your ~/.bash_profile and include this:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
Install gems and build the app
gem install bundler bundle install rails secret # copy/paste the output as `encryption_key` in `config/settings.yml` rails db:create:all rails db:migrate db:seed rails dartsass:build rails tailwindcss:build RAILS_ENV=test rails db:test:prepare RAILS_ENV=test rails db:seed Once everything is set up, start the server with rails server and direct your web browser to localhost:3000/admin/overviews. Write down the username/password (these are only shown once) and follow the directions.
Most users are using Amazon S3 or Heroku. Thus we have decided to have a setup easy to get your site up and running as quickly as possible in this production environment. Hence you should add the following ENV variables:
S3_BUCKET_NAME => your bucket on AWS (or FOG_DIRECTORY for backward compat) AWS_ACCESS_KEY_ID => your access key on AWS AWS_SECRET_ACCESS_KEY => your secret key on AWS AWS_REGION => your AWS region (defaults to us-east-1) AUTHNET_LOGIN => if you use authorize.net otherwise change config/settings.yml && config/environments/*.rb AUTHNET_PASSWORD => if you use authorize.net otherwise change config/settings.yml && config/environments/*.rb On linux:
export S3_BUCKET_NAME=xxxxxxxxxxxxxxx export AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxx export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx export AWS_REGION=us-east-1 export AUTHNET_LOGIN=xxxxxxxxxxx export AUTHNET_PASSWORD=xxxxxxxxxxxxxxx On Heroku:
heroku config:set S3_BUCKET_NAME=xxxxxxxxxxxxxxx heroku config:set AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxx heroku config:set AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx heroku config:set AWS_REGION=us-east-1 heroku config:set AUTHNET_LOGIN=xxxxxxxxxxx heroku config:set AUTHNET_PASSWORD=xxxxxxxxxxxxxxx This is needed for using sendgrid on heroku(config/initializers/mail.rb):
heroku config:set SENDGRID_USERNAME=xxxxxxxxxxx heroku config:set SENDGRID_PASSWORD=xxxxxxxxxxxxxxx If you just want to see what ror_ecommerce looks like, before you enter any products into the database, run the following command:
rails db:seed_fake If you have not already done so point your browser to http://lvh.me:3000/admin/overviews and set up the admin user.
You should now have a minimal dataset, and be able to see a demo of the various parts of the app. Note: make sure you have config/settings.yml set up correctly before you try to checkout. Also, please take a look at The 15 minute e-commerce video.
If you would like to read the docs, you can generate them with the following command:
yardoc --no-private --protected app/models/*.rb First, create config/settings.yml and change the encryption key and paypal/auth.net information. You can also change config/settings.example.yml to config/settings.yml until you get your real info.
To change from authlogic to any other gateway look at the documentation HERE
Product images are handled by Active Storage. Storage backends are configured in config/storage.yml (disk for development/test, S3 for production).
The Image model uses has_one_attached :photo and provides variant sizes via Image::IMAGE_STYLES. Use image.photo_url(:small) to get a resized variant.
For image processing to work, you need the image_processing gem (included in the Gemfile) and either libvips or ImageMagick installed locally:
# macOS (libvips recommended) brew install vips # or ImageMagick brew install imagemagickProduct search is powered by Searchkick, which uses Elasticsearch under the hood. It provides typo-tolerant, relevance-ranked full-text search across product names, keywords, and descriptions.
The Product model includes the ProductSearch concern (app/models/concerns/product_search.rb), which:
- Declares
searchkick word_start: [:name]for autocomplete-friendly matching on product names - Indexes
name(boosted 2x),product_keywords,description_markup, anddeleted_at - Provides
Product.standard_search(query, page:, per_page:)used by the storefront search (ProductsController#create) - Falls back to a SQL
LIKEquery if Elasticsearch is unreachable, so the app remains functional without ES running
- Install and start Elasticsearch:
brew install elasticsearch brew services start elasticsearch- Reindex products (required after initial seed or any time you want to rebuild the index):
rails runner "Product.reindex"The db:seed_fake rake task automatically reindexes products after seeding.
If Elasticsearch is not running, product search degrades gracefully to SQL LIKE queries on products.name and products.meta_keywords. Admin product grids (Product.admin_grid) do not use Elasticsearch at all.
The test suite uses RSpec with a MySQL test database. Before running tests for the first time:
RAILS_ENV=test rails db:create db:migrate db:seed rails dartsass:buildThen run the full suite:
bundle exec rspecSearchkick callbacks are disabled globally in spec_helper.rb (Searchkick.disable_callbacks in before(:each), re-enabled in after(:each)). This means:
- Elasticsearch does not need to be running to run the test suite. Product saves skip indexing entirely.
- Search specs exercise the SQL fallback path by default, which verifies that search degrades gracefully.
- If you need to test actual Elasticsearch search behavior in a spec, enable callbacks and reindex within the test:
it "returns matching products from Elasticsearch" do Searchkick.enable_callbacks product = FactoryBot.create(:product, name: "Red Widget") Product.reindex results = Product.standard_search("Red Widget") expect(results).to include(product) endThe admin area uses CanCanCan for authorization, defined in app/models/admin_ability.rb. There are five admin roles:
| Role | Key Permissions |
|---|---|
Super Admin (super_admin?) | Full read/write access to everything (can :manage, :all) |
Admin (admin?) | Read-only on all resources, plus view users, create orders, manage fulfillment, and manage coupons |
Warehouse (warehouse?) | Read products/variants, manage purchase orders, manage fulfillment, read orders |
Customer Service (customer_service?) | Read orders and users, view users, manage return authorizations |
Report (report?) | Read-only access to reports |
Edit app/models/admin_ability.rb and add can rules under the appropriate role block. Controllers that need explicit checks should call authorize! or use authorize_resource. See the CanCanCan docs for details.
The app uses Propshaft for serving assets and three CSS/JS tools:
- Tailwind CSS (
tailwindcss-rails) for storefront styling. Design tokens live inapp/assets/tailwind/application.cssusing Tailwind v4's@themeblock. - dartsass-rails for admin SCSS compilation (
admin_new.scssand related admin stylesheets). - importmap-rails with Turbo and Stimulus for all JavaScript (both admin and storefront).
After changing stylesheets, rebuild with:
rails dartsass:build # admin SCSS rails tailwindcss:build # storefront Tailwind In development, use bin/dev (powered by Procfile.dev) to auto-compile both on save:
bin/dev Compiled CSS is output to app/assets/builds/ (gitignored). Propshaft serves these alongside static assets.
The application was upgraded from Rails 8.0 to Rails 8.1.2. Key changes:
- Framework defaults:
config.load_defaults 8.1with two legacy overrides inconfig/application.rb(belongs_to_required_by_default = falseandaction_on_open_redirect = :log). - Schema sorting:
db/schema.rbcolumns are now sorted alphabetically (Rails 8.1 default). - Form helpers:
number_fieldandnumber_field_tagno longer accept a separate HTML options hash as a third argument. All options must be merged into a single hash (e.g.f.number_field :qty, step: 1, class: "form-control"). - Open redirects:
raise_on_open_redirectswas deprecated in favor ofaction_on_open_redirect. - Removed defaults files:
new_framework_defaults_7_0.rbandnew_framework_defaults_8_0.rbhave been removed; their overrides are consolidated inconfig/application.rb.
The wireframes/ directory contains standalone HTML mockups for anyone looking to give the app a fresh look and feel. Open them directly in a browser for a quick preview.
Admin layouts:
- Option A — Sidebar Dashboard — collapsible left sidebar with icon+label navigation
- Option B — Top-Nav Command Palette — horizontal top nav with a spotlight-style search
- Option C — Two-Tier Hybrid — slim icon sidebar + horizontal sub-nav tabs
Storefront layouts:
- Storefront A — Minimal Editorial — clean, whitespace-driven product grid
- Storefront B — Magazine Storytelling — hero-image-forward, editorial-style layout
These are starting points for inspiration — pick one, remix it, or build your own.
- more documentation
- Evaluate migrating from Authlogic to Rails' built-in
has_secure_password+authenticate_by - Evaluate Solid Cache / Solid Queue for background jobs and caching
Typically a product has many variants. (Variant ~= specific size of a given shoe)
If you have many variants with the same image don't bother with an image group, just use the "products.images".
Use ImageGroups for something like shoes. Lets say you have 3 colors, and each color has 10 sizes. You would create 3 images groups (one for each color). The image for each size would be the same and hence each variant would be associated to the same image_group for a given color.
RoR Ecommerce was created by David Henner. Contributors.
Shipping categories are categories based off price:
you might have two shipping categories (light items) & (heavy items) where heavy items are charged per item purchased and light items are charged once for all items purchased. (hence buying 30 feathers has the same shipping charges as one feather)
Have fun!!!