Displaying 1 result from an estimated 1 matches for "scope_to_user".
Did you mean:
copy_to_user
2006 Jul 02
11
Rails Plugin: meantime_filter for controllers (actions within blocks)
...type of filter yields
when the action has to be performed. Especially, it enables one to
use all the power of the ActiveRecord::Base.with_scope class method
in actions.
For example (in a controller definition):
before_filter :authenticate # Sets @user to the logged in user
meantime_filter :scope_to_user, :only => :list
# Displays the posts of @user only.
def list
@posts = Post.find(:all)
end
private
def scope_to_user
Post.with_scope(:find => { :conditions => [''user_id = ?'',
@user.id] }) { yield }
end
A good thing is that nested filters are supported. Y...