First of all, I think you should probably leave the FaultCommentsController
like it came, which was probably something like this:
def create
@fault_comment = FaultComment.new(params[:fault_comment])
@fault_comment.user = current_user
if @fault_comment.save
redirect_to faults_path
end
end
(As a side note, it would probably be worth your while to learn about CamelCase and snake_case and how to properly translate between the two. The snake_case corollary to FaultComment
is fault_comment
, not faultcomment
. You will certainly run into problems if you don't understand this.)
Your form on views/faults/show.html.erb
looks more or less right to me. If you change your controller back to the original, does it work?
Also, change your form like this:
<h3>Add New</h3>
<%= form_for @fault_comment, :url => fault_comments_path do |f| %>
<%= f.text_field :comment %>
<%= f.hidden_field :fault_id, @fault.id %>
<%= f.submit %>
<% end %>