1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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

This commit is contained in:
kennyj 2012-04-12 20:33:06 +09:00
parent 8248f4202d
commit 0f3901e910
3 changed files with 4 additions and 3 deletions

View file

@ -77,7 +77,7 @@ module ActiveRecord
end end
def stale_state def stale_state
owner[reflection.foreign_key].to_s owner[reflection.foreign_key] && owner[reflection.foreign_key].to_s
end end
end end
end end

View file

@ -27,7 +27,8 @@ module ActiveRecord
end end
def stale_state 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 end
end end

View file

@ -62,7 +62,7 @@ module ActiveRecord
# properly support stale-checking for nested associations. # properly support stale-checking for nested associations.
def stale_state def stale_state
if through_reflection.macro == :belongs_to 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
end end