Is it possible to show validation error messages from controller by making our method ? please check the code below
validate :validation
def validation
if self.RJan.nil? && self.RFeb.nil? && self.RMar.nil? && self.R1.nil?
#How do write my error message here ?
end
end
and my form
<% if @record.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@record.errors.count, "error") %> prohibited this record from being saved:</h2>
<ul>
<% @record.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>