class PeanutGallery::InstallGenerator

Public Instance Methods

add_comment_model() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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