From: Josh Cheek Date: 2009-10-15T00:10:10+09:00 Subject: Re: Ruby sql question --000e0cd1530afec3130475e68e5a Content-Type: text/plain; charset=ISO-8859-1 On Wed, Oct 14, 2009 at 9:47 AM, Manish Sharma wrote: > Leslie Viljoen wrote: > > On Wed, Oct 14, 2009 at 4:24 PM, Manish Sharma > > wrote: > >> Hi, > >> > >> Im using ActiveRecord to find something. > >> > >> <% @new = User.find_by_sql("SELECT * FROM users WHERE users.id NOT IN > >> (array)") %> > >> > >> Now, i can't seem to make it look through the array. I had a look for > >> this problem in other languages and in php its simply $array. > > > > Perhaps: > > "SELECT * FROM users WHERE users.id NOT IN (#{array.join(', ')})" > > Just an extra question though. what does the array.join(',') do? > -- > Posted via http://www.ruby-forum.com/. > > http://www.ruby-doc.org/core/classes/Array.html#M002182 Returns a string created by converting eachelement of the array to a string, separated by *sep*. [ "a", "b", "c" ].join #=> "abc" [ "a", "b", "c" ].join("-") #=> "a-b-c" Also, your use of erb and ActiveRecord implies a MVC structure. If this is the case, you should be assigning instance variables in your controller and not your view. You should not have find statements or assignments in your view, it should only be for formatting output. --000e0cd1530afec3130475e68e5a--