Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
def create_field(field, field_attributes)
# Multiple values
if field_attributes.is_a?Array or field_attributes.is_a?ActiveRecord::Associations::CollectionProxy
multiple_values = []
field_attributes.each do |atr|
atr = atr.attributes if field_attributes.is_a?ActiveRecord::Associations::CollectionProxy
atr.reject! {|k,v| k.eql?"id" }
atr.merge!({ :user_id => })
multiple_values <<
end "#{field}=", multiple_values
# Single values
field_attributes.reject! {|k,v| k.eql?"id" }
field_attributes.merge!({ :user_id => }) "#{field}=",

This comment has been minimized.

Copy link

@gil27 gil27 commented May 29, 2014

Uma outra abordagem: Assim tentamos respeitar o princípio de single responsability dos métodos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.