app/views/comments/_form.html.erb
<div id="comment_new">
<%= form_for(@comment) do |f| %>
<% if @comment.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>
<ul>
<% @comment.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= user_picture(current_user, :class => 'borda_vinho') %>
<%= f.text_area :body %>
</div>
<%= f.hidden_field :proposal_id %>
<div class="actions_com">
<%= image_submit_tag 'comment.png', :class => 'submit_comment' %>
</div>
<% end %>
</div>
<%= content_for :js do %>
<script>
$(document).ready(function() {
var validator = $("#new_comment").validate({
rules: {
'comment[body]': "required"
},
messages: { 'comment[body]': 'Comment cannot be empty' }
});
});
</script>
<% end -%>