Owner-filtered model objects on Rails 3
I need to do some filtering on my ActiveRecord models, I want to filter all my model objects by owner_id. The thing I need is basically the default_scope for ActiveRecord. But I need to filter by a session variable, which is not accessible from the model. I've read some solutions , but none works, basically any of them says that you can use session when declaring default_scope. This is my declaration for the scope: class MyModel < ActiveRecord::Base default_scope { where(:owner_id => session[:user_id]) } ... end Simple, right?. But it fails saying that method session does not exists . Hope you