I am new to Ruby on Rails and stack overflow. Sorry if there are errors in asking this question or ...
I am trying to write an edit / update for my blogger project. This is my controller:
def edit @post = Post.find params[:id] end def update @post.update(params[:post].permit(:title, :summary, :content)) redirect_to posts_path end
This is my opinion:
<h1>Edit Page</h1> <%= form_for @post do |f| %> Title: <%= f.text_field :title %> Summary: <%= f.text_area :summary %> Content: <%= f.text_area :content %> <%= f.submit "Update" %> <% end %>
and when I want to update any record, I keep getting this error:
NoMethodError in PostsController Update #
undefined `update 'method for nil: NilClass
Any help would be appreciated! :)
user2614238
source share