We have a Page model which acts_as_paranoid.

AAP modifies ActiveRecord finders to ignore any records marked as
deleted unless the :with_deleted => true option is supplied.

We have a UI element which allows users to toggle whether or not to
display deleted Pages, their current setting being stored in a session
variable, session[:show_deleted].

What we would like is to automagically have :with_deleted => session
[:show_deleted] appended to all calls to find, all, first, find_by_
etc.

That would be easy enough to do with an alias_method_chain but for the
fact that session data is not available when the call is being made
from a model.

I know accessing session data in a model is controversial, but can
anyone suggest a workaround? Or alternatively another approach to
being able to easily switch between including/ignoring deleted records
in all finder methods?

Thanks.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to