On Monday, August 18, 2014 2:57:05 AM UTC+1, Phil wrote:
>
>
> Is there a way to turn this sort of caching off globally?  (Other caching 
> is fine, I don't want to turn all caching off.)
>
>
> BTW- It is a bit mind blowing that this is turned on by default.  Possible 
> data corruption shouldn't ever be preferred by default over (possible) 
> speed gains.  I'd still categorize this as a serious bug, at least as a 
> configuration default.
>
>
> Not that I know of. As of rails 4 (or is it 3.2?) the generated 
association accessors are defined in a module (rather than directly on the 
class so it's easy enough to override them so you could do

class TestParent
   has_many :test_children

   def test_childen(force_reload=true)
     super(force_reload)
   end
end 

To change it for all associations without having to do this on a per 
association basis would probably require some monkey patching inside the 
activerecord code - sounds brittle.

As tamouse says if you use build/create on the association then you won't 
see this behaviour, although there can still be differences between the 
array thus constructed in memory and the array you'd get if you had 
selected from the database (for example if you have an order clause on the 
association, custom select  etc.)

Rails has been like this at least since the 1.0 days - I can't say I've 
ever run into particular issues from it.

Fred

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/b8dc881a-3d48-4671-bbe3-e85011a5474b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to