Class: Spina::Shop::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Spina::Shop::InstallGenerator
- Defined in:
- lib/generators/spina/shop/install_generator.rb
Instance Method Summary collapse
- #copy_migrations ⇒ Object
- #default_product_category ⇒ Object
- #default_sales_category ⇒ Object
- #feedback ⇒ Object
- #import_countries ⇒ Object
- #run_migrations ⇒ Object
Instance Method Details
#copy_migrations ⇒ Object
5 6 7 8 |
# File 'lib/generators/spina/shop/install_generator.rb', line 5 def copy_migrations return if Rails.env.production? rake 'spina_shop:install:migrations' end |
#default_product_category ⇒ Object
18 19 20 21 |
# File 'lib/generators/spina/shop/install_generator.rb', line 18 def default_product_category default_product_category = Spina::Shop::ProductCategory.where(name: 'Default').first_or_initialize default_product_category.save end |
#default_sales_category ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/spina/shop/install_generator.rb', line 23 def default_sales_category default_sales_category = Spina::Shop::SalesCategory.where(name: "Default").first_or_initialize default_sales_category.codes = { world: { default: "0" } } default_sales_category.save end |
#feedback ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/generators/spina/shop/install_generator.rb', line 33 def feedback puts puts ' Your Spina Shop has been succesfully installed! ' puts puts ' Restart your server and visit http://localhost:3000 in your browser!' puts " The admin backend is located at http://localhost:3000/#{Spina.config.backend_path}." puts end |
#import_countries ⇒ Object
14 15 16 |
# File 'lib/generators/spina/shop/install_generator.rb', line 14 def import_countries rake 'spina_shop:import_countries' end |
#run_migrations ⇒ Object
10 11 12 |
# File 'lib/generators/spina/shop/install_generator.rb', line 10 def run_migrations rake 'db:migrate' end |