Sunday, February 24, 2013

Re: [Rails] where condition with array


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 

I'm still analyzing it but it taught me a lot

Javier

--
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


Real Estate