I am trying to create a custom version of this below
accepts_nested_attributes_for :categories, :reject_if => proc { |hash| hash['title'].blank? }
So far what i got is
def categories_attributes=(categories_attributes)
categories_attributes.values.each do |category_attribute|
category = Category.find_or_create_by(category_attribute)
categories << category
end
end
But i am trying to add the reject_if part to it, i cant seem to figure it out. how can i replicate that portion into my custom attribute below?
Thanks!
Aucun commentaire:
Enregistrer un commentaire