Browse files

- Active Resource Fix has_many association, update resource list

  after some methods
  • Loading branch information...
1 parent 3666989 commit 8edb72ce466a73b054c3d12adf502da8c3b0f726 @gramos committed Oct 1, 2010
View
2 activeresource/lib/active_resource/associations.rb
@@ -121,6 +121,7 @@ def has_many(resource, opts = {})
def collection.<<(member)
member.#{o[:association_col]} = #{id}
member.save
+ super(member)
end"
instance_eval "
@@ -133,6 +134,7 @@ def collection.delete(member)
instance_eval "
def collection.clear
self.each{|member| delete(member)}
+ super
end"
collection
View
2 activeresource/test/cases/associations_test.rb
@@ -22,7 +22,7 @@ class Milestone < ActiveResource::Base
@other_project_manager = {:id => 6, :name => "John", :project_id => nil}
@project_managers = [@project_manager]
@milestone = { :id => 1, :title => "pre", :project_id => nil}
-@other_milestone = { :id => 2, :title => "rc", :project_id => nil}
+@other_milestone = { :id => 2, :title => "rc other", :project_id => nil}
ActiveResource::HttpMock.respond_to do |mock|
mock.get "/projects/.xml", {}, @project.to_xml(:root => 'project')

0 comments on commit 8edb72c

Please sign in to comment.