Class: Blocky::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Blocky::InstallGenerator
- Defined in:
- lib/generators/blocky/install_generator.rb
Instance Method Summary collapse
- #ask_questions ⇒ Object
- #create_initializer_file ⇒ Object
- #install_migrations ⇒ Object
- #mount_engine ⇒ Object
Instance Method Details
#ask_questions ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/generators/blocky/install_generator.rb', line 5 def ask_questions @blocky_route = ask("What route should be used to manage content blocks? [/admin/content]") if @blocky_route.blank? @blocky_route = "/admin/content" end @user_class = ask("What class is used for user authentication? [User]") if @user_class.blank? @user_class = "User" end end |
#create_initializer_file ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/generators/blocky/install_generator.rb', line 17 def create_initializer_file create_file "config/initializers/blocky.rb", <<-INITIALIZER Blocky.user_class = "#{@user_class}" Blocky.s3_access_key_id = ENV["BLOCKY_S3_KEY"] Blocky.s3_secret_access_key = ENV["BLOCKY_S3_SECRET"] Blocky.s3_bucket = ENV["BLOCKY_S3_BUCKET"] INITIALIZER end |
#install_migrations ⇒ Object
26 27 28 |
# File 'lib/generators/blocky/install_generator.rb', line 26 def install_migrations rake "blocky:install:migrations" end |
#mount_engine ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/generators/blocky/install_generator.rb', line 30 def mount_engine insert_into_file(File.join("config", "routes.rb"), :after => "Application.routes.draw do\n") do <<-MOUNTENGINE # This line mounts Blocky's routes to the path '#{@blocky_route}'. # This means, any requests to '#{@blocky_route}', will go to Blocky::ContentBlocksController. # If you would like to change where this engine is mounted, simply change the :at option to something different. mount Blocky::Engine, at: "#{@blocky_route}" MOUNTENGINE end end |