I have a model with its checks, and I found out that I cannot update the attribute without checking the object before.
I already tried to add the syntax on => :create at the end of each line of validation, but I got the same results.
My ad model has the following validations:
validates_presence_of :title validates_presence_of :description validates_presence_of :announcement_type_id validate :validates_publication_date validate :validates_start_date validate :validates_start_end_dates validate :validates_category validate :validates_province validates_length_of :title, :in => 6..255, :on => :save validates_length_of :subtitle, :in => 0..255, :on => :save validates_length_of :subtitle, :in => 0..255, :on => :save validates_length_of :place, :in => 0..50, :on => :save validates_numericality_of :vacants, :greater_than_or_equal_to => 0, :only_integer => true validates_numericality_of :price, :greater_than_or_equal_to => 0, :only_integer => true
My rake task does the following:
task :announcements_expiration => :environment do announcements = Announcement.expired announcements.each do |a|
This outputs all validation exceptions for this model to the output file.
Can anyone update an attribute without checking the model?
validation ruby-on-rails
Brian Roisentul Jun 08 '10 at 15:27 2010-06-08 15:27
source share