acts_as_lookup 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/acts_as_lookup.gemspec +1 -1
- data/lib/acts_as_lookup.rb +5 -2
- metadata +1 -1
data/acts_as_lookup.gemspec
CHANGED
data/lib/acts_as_lookup.rb
CHANGED
@@ -97,10 +97,13 @@ module ActsAsLookupClassMethods
|
|
97
97
|
acts_as_lookup_options[:values].each do |val|
|
98
98
|
next if @acts_as_lookup_by_id.include?(val[:id])
|
99
99
|
|
100
|
-
#
|
100
|
+
# bypass attr_accessible protection, assign attributes one-by-one
|
101
101
|
new_val = self.new
|
102
102
|
val.each_pair do |attr,value|
|
103
|
-
|
103
|
+
setter = "#{attr.to_s}=".to_sym
|
104
|
+
if new_val.respond_to?(setter)
|
105
|
+
new_val.send(setter, value)
|
106
|
+
end
|
104
107
|
end
|
105
108
|
new_val.save!
|
106
109
|
|