Class: PeanutGallery::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/peanut_gallery/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_comment_modelObject



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_routesObject



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_inheritanceObject



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