I'm a beginner in Ruby on Rails and stack overflow. So sorry if there are mistakes in asking this question or...
I'm trying to write 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 view:
<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 post I keep getting this error:
NoMethodError in PostsController#update
undefined method `update' for nil:NilClass
Any help will be appreciated! :)
before_filteris nowbefore_action- mbigras