Great !

Thanks Jim

Le mercredi 21 novembre 2012 15:04:57 UTC+1, jim a écrit :
>
>
>
>
> On Wed, Nov 21, 2012 at 9:33 PM, Erwin <[email protected] <javascript:>>wrote:
>
>> I wrote this scope in my Subdomain model :
>>
>>   scope :in_account, lambda { |account_id|
>>     if account_id == "*"
>>       where("account_id >= ?", 0)
>>     else
>>       where(account_id: account_id) 
>>     end
>>   }
>>
>> where account_id == '*'  then all subdomain instances are selected
>> when account_id is given , only subdomain instances in this account are 
>> selected
>>
>> is there a better writing ?
>>
>
> you can use scoped instead
>
> account_id == '*' ? scoped : where(account_id: account_id)  
>  
>
>>
>> thanks for feedback
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby on Rails: Talk" group.
>> To post to this group, send email to 
>> [email protected]<javascript:>
>> .
>> To unsubscribe from this group, send email to 
>> [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/rubyonrails-talk/-/3xoM8jq4ED8J.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> -------------------------------------------------------------
> visit my blog at http://jimlabs.heroku.com
>  

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/Y2teFjkW-McJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to