Ruby on Rails
Monday, February 25, 2013
Try something like this:
Plan.where("user_id not in (#{[3,4,7].join(', ')})")
2013/2/25 tamouse mailing lists <tamouse.lists@gmail.com>
On Sun, Feb 24, 2013 at 8:43 PM, Javier Quarite <jquarites@gmail.com> wrote:If going the SQL route, easier might be:
>
> Have you considered doing a sql query?
>
> my approach would be this
>
> query_array = []
> [3,4,7].each do |value|
> query_array << "user_id != #{value}"
> end
>
> Plan.where("#{query_array}.join(" and ")")
>
> Also, the past week I found this gist from ryan
> https://gist.github.com/ryanb/4974414
>
> I'm still analyzing it but it taught me a lot
>
> Javier
Plan.where("user_id not in (3,4,7)")
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment