I am doing a basic validation for a bank entry and am trying to display the errors on submit. Here is my validation and html.
class GuestbookEntry < ActiveRecord::Base
validates :body, presence: :true
end
This is my html:
<% form_for @guestbook_entry do |f| %>
<% if @guestbook_entry.errors.any? %>
<% @guestbook_entry.errors.full_messages.each do |m| %>
<li><%= m %></li>
<% end %>
<% end %>
<%= f.label :body, "Guestbook Entry:" %>
<%= f.text_area :body %>
<%= f.submit "Submit" %>
<% end %>
Any ideas?
Aucun commentaire:
Enregistrer un commentaire