I'm getting an undefined method 'model_name' error with simple_form when I want to edit a basic post on Rails 5.
show.html.haml:
= link_to "Edit", edit_post_path(@post)
edit.html.haml:
= simple_form_for @post do |f|
= f.input :title
= f.input :link
= f.input :description
= f.button :submit
posts_controller.rb:
def show
@post = Post.find(params[:id])
end
def edit
end
def update
if @post.update(post_params)
redirect_to @post
else
render 'edit'
end
end
Any idea?
editaction in controller?@post = Post.find(params[:id])toeditactionnil:NilClass", implying that your@postvariable wasnil.