On Jun 3, 4:30 am, dasibre <[email protected]> wrote:
> I have a model, Work, that when I create a new instance with
> incorrect

Why not post your controller code as several people have asked rather
than reposting your original question.

Fred



> field data does not call the validation methods. When I update an
> existing instance with the same incorrect fields the validation
> methods are called.
> The create action fails on the save method and re-routes to the new
> action, causing runtime errors.
> I dont understand why update validates correctly and create doesn't.
> Validation lines in the model are as follows:
> validates :start, :presence => { :message => "must be a valid date/
> time" }
> validates :end, :presence => {:message => "must be a valid date/
> time"}
> validate :start_must_be_before_end_time
> def start_must_be_before_end_time
>     errors.add(:start, "must be before end time") unless
>         self.start < self.end
> end
> Any pointers would be great.
>
> I think your (validation :start, :presence )
> seems to be missing the "true" option.
>
> validation :start, :presence => true, :message => "must be a
> valid......
>
> On May 31, 3:50 pm, flaps <[email protected]> wrote:
>
>
>
>
>
>
>
> > I have a model, Work, that when I create a new instance with incorrect
> > field data does not call the validation methods. When I update an
> > existing instance with the same incorrect fields the validation
> > methods are called.
>
> > The create action fails on the save method and re-routes to the new
> > action, causing runtime errors.
>
> > I dont understand why update validates correctly and create doesn't.
>
> > Validation lines in the model are as follows:
>
> > validates :start, :presence => { :message => "must be a valid date/
> > time" }
> > validates :end, :presence => {:message => "must be a valid date/
> > time"}
> > validate :start_must_be_before_end_time
>
> > def start_must_be_before_end_time
> >     errors.add(:start, "must be before end time") unless
> >         self.start < self.end
> > end
>
> > Any pointers would be great.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to