I am trying to display validation errors in the view. When i try to save this the error is raised both in the view and logs instead with my custom message additional filter type is required
Here is my code
Model
class AdditionalFilter < ActiveRecord::Base
validates :additional_filter_type, presence:{ message: "additional filter type is required" }
end
View
<% if @form.errors.any? %>
<%= @form.errors%> <!-- i know should just display an array -->
<%end%>
I am using Rails 4. Any help will be appreciated, or even guidance how to debug this.Thank you
Here is the error in the log
ActiveRecord::RecordInvalid - Validation failed: Additional filters additional filter type additional filter type is required:
activerecord (4.2.3) lib/active_record/validations.rb:79:in `raise_record_invalid'
activerecord (4.2.3) lib/active_record/validations.rb:43:in `save!'
Aucun commentaire:
Enregistrer un commentaire