lib/active_resource/associations.rb in embark-journey-0.0.8 vs lib/active_resource/associations.rb in embark-journey-0.0.9
- old
+ new
@@ -130,11 +130,11 @@
instance_variable_get(ivar_name)
elsif attributes.include?(method_name)
attributes[method_name]
elsif association_id = send(finder_key)
return nil if association_id.blank?
- instance_variable_set(ivar_name, association_model.find(association_id))
+ instance_variable_set(ivar_name, (association_model.find(association_id) rescue nil))
end
end
define_method("#{method_name}=") do |obj|
instance_variable_set(ivar_name, obj)
@@ -143,10 +143,10 @@
end
attr_accessor :embeds
def defines_belongs_to_embed(method_name, association_model, foreign_key)
self.embeds ||= []
- self.embeds << association_model.to_s.underscore
+ self.embeds << method_name.to_s
end
def defines_has_many_finder_method(method_name, association_model)
ivar_name = :"@#{method_name}"