I am using rails 2.3.5. I have a Blog model and Blog has many comments. This is my Blog controller show action
def show
@blog = Blog.find(params[:id])
@comment = Comment.new
end
I would display the Blog and at the end would have an option for creating comment. So I add this in blogs/show.html.erb.
<% form_remote_for @comment do |f| %>
<%= f.label :content %>
<%= f.text_area :content, :rows => 6 %>
<%= f.hidden_field :blog => @blog %>
<%= f.submit %>
<% end %>
But i get the following error when i run this NoMethodError in Blogs#show
Showing app/views/blogs/show.html.erb where line #270 raised:
undefined method `blog#<Blog:0xb677d8d0>' for #<Comment:0xb67762b0>
Extracted source (around line #270):