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