I have a very simple question with rails, but I can not find the answer anywhere. I assume some of the problems are related to me after the Rails 1.2 tutorial with Rails 2.1. Anyway..
I am writing a blog system and I am implementing a bit of comments. I have comments displaying a penalty as soon as I created them using the script / console, but getting the comment form itself is a hard bit.
In posts_controller.rb I have
def comment
Post.find(params[:id]).comments.create(params[:comment])
flash[:notice] = "Added comment"
redirect_to :action => show
end
and in show.html.erb (view) I have
<%= form_tag :action => "comment", :id => @post %>
<%= text_area "comment", "body" %><br>
<%= submit_tag "Post Comment" %>
When I submit the form, it tries to go to UBL / posts / comment / 1, which is clearly wrong, and complains that it cannot find the template. Obviously, I don’t want the template to be there, because I told him to redirect the show to the action, because I want it to simply display the page after showing with a new comment.
(render: action = > show), redirect_to, .
, - , ?