Just joking 😛 Will be a big challenge for me because I’ll move from specific field, web and social network analysis, to general purpose development where projects are really varied: custom CMS, integration with IoT devices, mobile application and many others. In the end, a good challenge!
eCommerce solutions are quite popular in Curcuma’s portfolio and my last experience about was in 2008 with an early version of Magento. I worked on similar products but I’m quite “rusty” on this topic. Starting from the Ruby ecosystem, default in Curcuma, only two realistic options are available: Spree (acquired by First Data and no longer supported) and Solidus (a Spree fork quite young but already interesting).
I searched for tutorials about Solidus but version 1.0.0 was shipped last August (and is based on Spree 2.4) and community is still young. I found only beginner’s tutorials so I decided to follow Github README instructions on master branch.
Start with a fresh installation of Rails 4.2 (Rails 5.0 beta seems not supported yet), add gems and run
gem 'solidus' gem 'solidus_auth_devise'
Gemfile.lock you can find solidus dependencies:
solidus (1.2.2) solidus_api (= 1.2.2) solidus_backend (= 1.2.2) solidus_core (= 1.2.2) solidus_frontend (= 1.2.2) solidus_sample (= 1.2.2) solidus_auth_devise (1.3.0)
solidus package seems a container for these modules. I really like this approach: is clean, encourages isolation and mask complexity. Also gemspec is the cleanest I’ve seen yet.
# encoding: UTF-8 require_relative 'core/lib/spree/core/version.rb' Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'solidus' s.version = Spree.solidus_version s.summary = 'Full-stack e-commerce framework for Ruby on Rails.' s.description = 'Solidus is an open source e-commerce framework for Ruby on Rails.' s.files = Dir['README.md', 'lib/**/*'] s.require_path = 'lib' s.requirements << 'none' s.required_ruby_version = '>= 2.1.0' s.required_rubygems_version = '>= 1.8.23' s.author = 'Solidus Team' s.email = 'firstname.lastname@example.org' s.homepage = 'http://solidus.io' s.license = 'BSD-3' s.add_dependency 'solidus_core', s.version s.add_dependency 'solidus_api', s.version s.add_dependency 'solidus_backend', s.version s.add_dependency 'solidus_frontend', s.version s.add_dependency 'solidus_sample', s.version end
Setup and config
Anyway next step on README is to run following rake tasks
bundle exec rails g spree:install bundle exec rake railties:install:migrations
First one gives me a warning:
[WARNING] You are not setting Devise.secret_key within your application! You must set this in config/initializers/devise.rb. Here's an example: Devise.secret_key = "7eaa914b11299876c503eca74af..."
fires some actions related to assets, migrations and seeds then ask me for username and password. Standard install.
About the warning I found another post that recommend to run this task.
rails g solidus:auth:install
Is not clear to me what it does but seems working. After run warning is left.
Rake about migration (
bundle exec rake railties:install:migrations) gives no output. I suppose migrations are already installed after first step. No idea.
Anyway last step liste on README is to run migrations (
bundle exec rake db:migrate) and give no output too so everything seems ok.
No we can fire
rails s and enjoy our brand new store 😀
A bit more control
These steps are cool but do a lot of things we probably don’t want like install demo products and demo users. Following the README, installation can be run without any automatic step:
rails g spree:install --migrate=false --sample=false --seed=false
and then you are free to run any of the available step with your customizations
bundle exec rake railties:install:migrations bundle exec rake db:migrate bundle exec rake db:seed bundle exec rake spree_sample:load
Now our new store is ready. It’s time to dig deeper into Solidus structure. See ya in another post bro 😉