ruby on rails - Pass arguments in scope -


can provide example on how use

scope 

and parameters?

for example:

class permission < activerecord::base   scope :default_permissions, :conditions => { :is_default => true } end 

i have code returns default_permissions , want convert return default permissions given user (user_id)

thanks

new syntax (ruby 1.9+), prevent errors if don't supply user -

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

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -