THanks for your response. The validation methods are not called on a create, allowing the save method to be called, unprotected. I dont want the save to be called let alone fail.
The validation method should stop the save method from being run and redirect the user to the new action/view with errors displayed, right? The validation methods in the model are called on an update and errors reported back to the view. And I dont know why I am getting expected validating behaviour with an update but not with a create. I can post the error logs in the morning, but, on a create, they report a rollback, a 500 error, because the failed save call triggers the unexpected view to be routed. On May 31, 3:53 pm, Colin Law <clan...@googlemail.com> wrote: > On 31 May 2012 20:50, flaps <flaps2...@gmail.com> 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. > > The validation /should/ cause the save method to fail, that is the > whole point of validation. Or do you mean that the runtime errors > appear /during/ the save? If so then give us some more information > about that (the full error message and stack trace). > > Colin > > > > > > > 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 rubyonrails-talk@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- 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 rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.