Pass arguments in scope

ruby-on-rails, ruby-on-rails-3

Solution

new syntax (ruby 1.9+), that will prevent errors even if you don't supply the user -

scope :default_permissions_for, ->(user = nil) { ... }

Problem

Can someone provide an example on how to use ``` scope ``` and parameters? For example: ``` class Permission < ActiveRecord::Base scope :default_permissions, :conditions => { :is_default => true } end ``` I have this code that returns the default_permissions and I want to convert it to return the default permissions for a given user (user_id) Thanks

Original source