How do I add a condition to all ActiveRecords Queries for a particular model?
Posted
by Kyle West
on Stack Overflow
See other posts from Stack Overflow
or by Kyle West
Published on 2010-03-26T21:02:19Z
Indexed on
2010/03/26
21:03 UTC
Read the original article
Hit count: 450
ruby-on-rails
|activerecord
I am using the sentient_user gem to have access to the current_user object in my application. I want to override the default ActiveRecordBase queries to scope them to the current user.
For instance, I don't want my users looking at, deleting, modifying other user's orders.
I feel like I should be able to override a single (or couple) ActiveRecordBase methods to accomplish this, but I don't know which or how.
Thanks in advance.
© Stack Overflow or respective owner