Permalink
Browse files

@stale_state should be nil when a model isn't saved.

  • Loading branch information...
1 parent 8248f42 commit 0f3901e9101837eaab2daba5b01f67ed7e2c75d5 @kennyj kennyj committed Apr 12, 2012
@@ -77,7 +77,7 @@ def target_id
end
def stale_state
- owner[reflection.foreign_key].to_s
+ owner[reflection.foreign_key] && owner[reflection.foreign_key].to_s
end
end
end
@@ -27,7 +27,8 @@ def raise_on_type_mismatch(record)
end
def stale_state
- [super, owner[reflection.foreign_type].to_s]
+ foreign_key = super
+ foreign_key && [foreign_key.to_s, owner[reflection.foreign_type].to_s]
end
end
end
@@ -62,7 +62,7 @@ def construct_join_attributes(*records)
# properly support stale-checking for nested associations.
def stale_state
if through_reflection.macro == :belongs_to
- owner[through_reflection.foreign_key].to_s
+ owner[through_reflection.foreign_key] && owner[through_reflection.foreign_key].to_s
end
end

0 comments on commit 0f3901e

Please sign in to comment.