Class: PeanutGallery::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- PeanutGallery::InstallGenerator
- Defined in:
- lib/generators/peanut_gallery/install_generator.rb
Instance Method Summary collapse
Instance Method Details
#add_comment_model ⇒ Object
10 11 12 13 14 |
# File 'lib/generators/peanut_gallery/install_generator.rb', line 10 def add_comment_model cols = "item_id:integer item_type:string author_id:integer " cols += "markdown:text html:text" generate "model comment #{cols}" end |
#add_routes ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/generators/peanut_gallery/install_generator.rb', line 21 def add_routes routes = "\n namespace :peanut_gallery do\n" routes += " resources :comments, :only => [:create, :update, :destroy]\n" routes += " end\n" inject_into_file 'config/routes.rb', routes, :after => /Rails\.application\.routes\.draw\ do\n/ end |
#change_model_inheritance ⇒ Object
16 17 18 19 |
# File 'lib/generators/peanut_gallery/install_generator.rb', line 16 def change_model_inheritance gsub_file 'app/models/comment.rb', /ActiveRecord\:\:Base/, 'PeanutGallery::Comment' end |