Class: Chapter11_3::Generators::SolutionsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Chapter11_3::Generators::SolutionsGenerator
- Defined in:
- lib/generators/chapter11_3/solutions/solutions_generator.rb
Instance Method Summary collapse
Instance Method Details
#add_feed_method_to_user ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/chapter11_3/solutions/solutions_generator.rb', line 17 def add_feed_method_to_user dest = File.join(Rails.root, 'app', 'models', 'user.rb') insert_into_file(dest, :before => /end\s*\Z/) do # insert before end <<-CODE.gsub(/^\s+\|/,' ') |def feed | microposts |end CODE end end |
#add_microposts_resource ⇒ Object
10 11 12 13 14 15 |
# File 'lib/generators/chapter11_3/solutions/solutions_generator.rb', line 10 def add_microposts_resource dest = File.join(Rails.root,'config','routes.rb') insert_into_file(dest, :after => %r{resources\s+:users.*$}) do "\n resources :microposts, :only => [:create, :destroy]" end end |
#copy_app_tree ⇒ Object
6 7 8 |
# File 'lib/generators/chapter11_3/solutions/solutions_generator.rb', line 6 def copy_app_tree directory(self.class.source_root, Rails.root) end |