Forum: Ruby on Rails Why find_by_sql works and find(args) doesn't

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cdcdda30ac4e349c6ffd0819b9e1666f?d=identicon&s=25 Jay Pangmi (jaeezzy)
on 2008-10-09 03:01
I'm trying to use Campsite.find(:all, :condition => ['walk_id =
?',params[:walks][:id]]) but fails and instead, if I use
Campsite.find_by_sql("select * from campsites where walk_id =
"+params[:walks][:id]), it works fine. So, I'm wondering why..
I've created combo box as:
<%form_tag do%>
 <%=select :walks, :id, @great_walks%>
<%end%>

thanks.
A91bd6cef23eb3516245a092e196c4da?d=identicon&s=25 Maurício Linhares (mauricio)
on 2008-10-09 03:48
(Received via mailing list)
It's "conditions", not "condition":

Campsite.find(:all, :conditions => ['walk_id = ?',params[:walks][:id]])

On Wed, Oct 8, 2008 at 10:01 PM, Jay Pangmi
<rails-mailing-list@andreas-s.net> wrote:
> thanks.
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>



--
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
João Pessoa, PB, +55 83 8867-7208
This topic is locked and can not be replied to.