search for: check_if_empty

Displaying 1 result from an estimated 1 matches for "check_if_empty".

2009 Mar 17
4
Preventing a submitted hash from ActiveRecord DB store
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 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? --~--~---------~--~----~-------...