How to manually install ZXP extensions
Create new rails project. PostgreSQL database was used here, you can choose as per your requirements.
- rails new solidus-example — database=postgresql
Add the following to gemfile of your rails application.
- gem 'solidus'
- gem 'solidus_auth_devise'
As we have added the gems to the gemfile we need to update bundle.
- $ bundle install
In case you encounter nokogiri error you can refer to this link: http://stackoverflow.com/a/20006530
Add the necessary configurations in the config/database.yml like username password.
- default: &default
- adapter: postgresql
- encoding: unicode
- pool: 5
- username: postgres
- password: root
- host: localhost
- development:
- <<: *default
- database: solidus_example
- test:
- <<: *default
- database: solidus_example_test
Create the database.
- $ bundle exec rake db:create
After this you need to install spree.
- $ bundle exec rails g spree:install
It will ask for email and password (enter you custom) else go with the default ones.
- $ bundle exec rake railties:install:migrations
Now your solidus application is ready to be used. Now you can start your rails server and start exploring the feature and options available.
Creating solidus extension
To know more about extensions and how to write one in Spree refer http://guides.spreecommerce.org/developer/extensions_tutorial.html
Unlike Spree, it is not pretty straight forward in soldius, we need to add gem to our file.
- gem 'solidus_cmd'
And then we need to update bundle.
- $ bundle install
Now we need to move one directory back from the folder of our rails application and run following commands in the console.
- $ cd .. # To move one directory back in Linux systems
- $ gem install solidus_cmd
- $ solidus extension my_extension
- $ cd solidus_my_extension
- $ bundle install
Make sure you are now in solidus_my_extension folder. All the customisation that we need to do in solidus we must do it in this folder without touching the solidus-master code.
Now let’s add new column named as sale_price in the Spree::Variant model.
- bundle exec rails g migration add_sale_price_to_spree_variants sale_price:decimal
NOTE: Don’t run rake db:migrate in this folder.
First we need to update the .gemspec file of this extension. We need to add author, description, summary and email in .gemspec file. Below is sample.
- # encoding: UTF-8
- $:.push File.expand_path('../lib', __FILE__)
- require 'solidus_my_extension/version'
- Gem::Specification.new do |s|
- s.name = 'solidus_my_extension'
- s.version = SolidusMyExtension::VERSION
- s.summary = 'This is for test summary'
- s.description = 'This is for test description'
- s.license = 'BSD-3-Clause'
- s.author = 'Ankur'
- s.email = '[email protected]'
- # s.homepage = 'http://www.example.com'
- s.files = Dir["{app,config,db,lib}/**/*", 'LICENSE', 'Rakefile', 'README.md']
- s.test_files = Dir['test/**/*']
- s.add_dependency 'solidus_core', '~> 1.0'
- s.add_development_dependency 'capybara'
- s.add_development_dependency 'poltergeist'
- s.add_development_dependency 'coffee-rails'
- s.add_development_dependency 'sass-rails'
- s.add_development_dependency 'database_cleaner'
- s.add_development_dependency 'factory_girl'
- s.add_development_dependency 'rspec-rails'
- s.add_development_dependency 'rubocop', '0.37.2'
- s.add_development_dependency 'rubocop-rspec', '1.4.0'
- s.add_development_dependency 'simplecov'
- s.add_development_dependency 'sqlite3'
- end
Now move to the solidus-example folder.
Now we need to include our created extension in our main rails application. Add the following to the gemfile.
- gem 'solidus_my_extension', :path => '../solidus_my_extension'
Then run following commands.
- $ bundle install
- $ rails g solidus_my_extension:install
It will prompt you run the migrations type ‘Y’ and after the successful migration completion you will have sale_price added.
Para a personalização das Views e Controller você pode seguir os passos descritos após http://guides.spreecommerce.org/developer/extensions_tutorial.html#adding-a-controller-action-to-homecontroller
# NOTA: após cada mudança na extensão precisamos reiniciar o servidor solidus-example