dino d. wrote:
> def self.set_current_user user
> if user
> holder = user.id
> else
> holder = -1
> end
> reflect_on_association(:current_user_vote).options[:conditions] =
> "votes.user_id = #{holder}"
> self.current_user = user
> end
>
> This works fine, unless I enable config.cache_classes, then, the first
> user who accesses the site after the server is restarted gets his id
> set to current_user, and everyone else afterward gets the first guy's
> user_id set in the association.
Yes, this trick stopped working in 2.2 because the reflection
now caches its conditions SQL.
One workaround is
reflection = reflect_on_association(:current_user_vote)
reflection.options[:conditions] = "votes.user_id = #{holder}"
reflection.instance_eval { @sanitized_conditions = nil }
--
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---