ruby on rails - undefined method `popups_path' for # -
i create model, view , controller when added form code on new.html.haml file. started showing error. routes defined follows
model popups.rb
class popups < activerecord::base attr_accessible :title, :body, :slug, :pipelinetype end
controller popups_controller.rb
class popupscontroller < applicationcontroller def new @popups = popups.new end def create @popups = popups.new(params[:url]) if @popups.save flash[:popups] = @popups.id redirect_to new_popups_url else render :action => "new" end end def show @popups = popups.find(params[:id]) redirect_to @popups.url end end
views popups - new.html.haml
= simple_form_for @popups |f| = f.input :title = f.input :body = f.input :pipelinetype = f.input :slug = f.submit
routes.rb resources :popups, :only => [:show, :new, :create]
migrate file
create_table :popups |t| t.string :title t.text :body t.string :slug t.string :pipelinetype t.timestamps end
i getting following errors on given urls
:3000/popups/new - undefined method `popups_index_path' # **:3000/popups -** unknown action action 'show' not found maincontroller
initially created model , controller popup name change later popups suggested
is there wrong code or routes or missing someting.
i used http://www.sitepoint.com/building-your-first-rails-application-views-and-controllers/ reference
always remember when use resources
, should giving plural name(i.e, popups in case). if want singular name(i.e, popup) use resource
instead of resources
.
for more info, see singular resources
Comments
Post a Comment