Class: SpreeProductReviews::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SpreeProductReviews::Generators::InstallGenerator
- Defined in:
- lib/generators/spree_product_reviews/install/install_generator.rb
Instance Method Summary collapse
Instance Method Details
#add_migrations ⇒ Object
6 7 8 |
# File 'lib/generators/spree_product_reviews/install/install_generator.rb', line 6 def add_migrations run 'bundle exec rake railties:install:migrations FROM=spree_product_reviews' end |
#add_reviews_page_block ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/generators/spree_product_reviews/install/install_generator.rb', line 22 def add_reviews_page_block say_status :spree_product_reviews, "Adding Reviews block to Product Details sections", :green # Load app environment explicitly (important for generators) require Rails.root.join("config/environment") Spree::PageSection .where(type: "Spree::PageSections::ProductDetails") .find_each do |section| next if section.blocks.exists?( type: "Spree::PageBlocks::Products::Reviews" ) section.blocks.create!( type: "Spree::PageBlocks::Products::Reviews", position: section.blocks.maximum(:position).to_i + 1 ) end end |
#run_migrations ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/generators/spree_product_reviews/install/install_generator.rb', line 10 def run_migrations run_migrations = [:migrate] || ['', 'y', 'Y'].include?( ask('Would you like to run the migrations now? [Y/n]') ) if run_migrations run 'bin/rails db:migrate' else puts 'Skipping rails db:migrate, don\'t forget to run it!' end end |