0 Replies - 954 Views - Last Post: 20 September 2016 - 10:26 PM Rate Topic: -----

#1 optweets  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 20-September 16

custom attributes version of accepts_nested_attributes_for with reject

Posted 20 September 2016 - 10:26 PM

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!

For what im trying to do, i need to make the custom version of it, although the accepts_nested_attributes_for works.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1