@Wolas!, I figured a validation will do the trick but knew something simpler had to be there.
@Fred, Dint count on it being SO simple!! :D <bangin head on wall> Thanks guys. returning "false" did the trick. On Mar 17, 2:22 pm, Frederick Cheung <[email protected]> wrote: > On Mar 17, 5:58 am, Ram <[email protected]> wrote: > > > Hi all, > > > I have a multi model form (Project with many tasks) and I want to > > prevent a task from being saved to the DB if it is empty ie. if there > > is no i/p for that task from the user. I tried the following > > If you don't want the save to happen then you should return false from > your before_save. > > Fred > > > class Task < ActiveRecord::Base > > > before_save :check_if_empty > > ... > > > def check_if_empty > > self.destroy if description.blank? > > end > > > but i get this > > > TypeError in ProjectsController#create > > can't modify frozen hash > > > Is there a way to let ActiveRecord know not to save a record (which is > > a frozen hash in this case) to the DB? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

