Re: [Rails] where condition with array
On Sun, Feb 24, 2013 at 8:43 PM, Javier Quarite <jquarites@gmail.com> wrote:
>
> 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
If going the SQL route, easier might be:
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home