Skip to content

Commit

Permalink
@stale_state should be nil when a model isn't saved.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyj committed Apr 12, 2012
1 parent 8248f42 commit 0f3901e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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

Expand Down

0 comments on commit 0f3901e

Please sign in to comment.