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 ?

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].
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/-/3xoM8jq4ED8J.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to