Olá quando cadastro um novo comentario não exibe nenhuma menssagem de erro mas também o comentario não é criado , segue meu código:
#comments_controller.rb
class CommentsController < ApplicationController
def create()
@job = Job.find(params[:job_id])
@comment = @job.comments.build(comment_params())
@comment.save
redirect_to @job
end
private
def comment_params()
return parametros = params.require(:comment).permit(:name , :text)
end
end
#_form.html.erb
<%= form_for [@job , Comment.new] do |f| %>
<div class = "form-group" >
<%= f.label :name %>
<br/>
<%= f.text_field :name %>
</div>
<div class = "form-group" >
<%= f.label :body %>
<br/>
<%= f.text_area :body %>
</div>
<div class = "actions" >
<%= f.submit "Send" %>
</div>
<% end %>
#show.html.erb
<p id="notice"><%= notice %></p>
<h1> <%= job_title(@job) %> </h1>
<%= simple_format @job.description %>
<p>
<%= pluralize(@job.comments.size , "comments")%>
</p>
<%= link_to 'Edit', edit_job_path(@job) %> |
<%= link_to 'Back', jobs_path %>
<h2> Send a Comment </h2>
<%= render "comments/form" %>
<h2> Comments </h2>
<%= render @job.comments %>
#routes.rb
Rails.application.routes.draw do
resources :jobs do
post "comments" , to: "comments#create"
end
root to: "jobs#premium"
get 'hello/world'
end