Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How do I change an ActiveRecord from marked to be saved to make sure it does not get saved, from within the model itself?
- before_save :ignore_new_delete_exisiting_if_blank(self.attribute)
- def ignore_new_delete_exisiting_if_blank(attribute)
- self.do_not_save_me! if attribute.blank?
- #what is that magic "do_not_save_me" method?
- #Is there such thing, or something to achieve the same thing?
- end
- def ignore_new_delete_exisiting_if_blank_attribute
- if attribute.blank?
- errors.add(:base, "Not allowed to save if attribute is blank.")
- end
- end
- validates_presence_of :attribute
- accepts_nested_attributes_for :posts, :reject_if => proc { |attributes| attributes['title'].blank? }
- def ignore_new_delete_exisiting_if_blank(attribute)
- attribute.present?
- end
Add Comment
Please, Sign In to add comment