Forum: Ruby on Rails Syntax Error in find()

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.
A111108ed3617edc35da89e84689c3c2?d=identicon&s=25 Arch Stanton (d6veteran)
on 2006-04-04 18:22
Maybe I misunderstand the parameterization of find(), I am getting this
syntax error for
<% @choices = Choic
e.find(:all, :conditions => "question_id" = question.id, :order =>
"order") %>


---- ERROR LOG ----


ActionView::TemplateError (compile error
../config/../app/views/admin/test/show.rhtml:37: syntax error
_erbout.concat "    ";  @choices = Choice.find(:all, :conditions =>
"question_id" = question.id, :order => "order") ; _erbout.concat "\r\n"
                                                                                   ^
../config/../app/views/admin/test/show.rhtml:37: syntax error
_erbout.concat "    ";  @choices = Choice.find(:all, :conditions =>
"question_id" = question.id, :order => "order") ; _erbout.concat "\r\n"
                                                                                                          ^
../config/../app/views/admin/test/show.rhtml:37: syntax error
_erbout.concat "    ";  @choices = Choice.find(:all, :conditions =>
"question_id" = question.id, :order => "order") ; _erbout.concat "\r\n"
                                                                                                                   ^)
on line #37 of app/views/admin/test/show.rhtml:
34:     <tr>
35:       <td><%= link_to question.question, :controller => "question",
:action => "show", :id => question.id %></td>
36:     </tr>
37:     <% @choices = Choice.find(:all, :conditions => "question_id" =
question.id, :order => "order") %>
38:       <% @choices.each do |choice| %>
39:     <tr>
40:       <td><%= link_to choice.choice, :controller => "choice",
:action => "show", :id => choice.id %></td>
119af50160cabfe1fb6f2f05f5018c64?d=identicon&s=25 James Ludlow (Guest)
on 2006-04-04 18:34
(Received via mailing list)
On 4/4/06, Arch Stanton <d6veteran@gmail.com> wrote:
> Maybe I misunderstand the parameterization of find(), I am getting this
> syntax error for
> <% @choices = Choic
> e.find(:all, :conditions => "question_id" = question.id, :order =>
> "order") %>

It looks like your conditions are messed up.

:conditions => ["question_id = ?", question.id]

-- James
A111108ed3617edc35da89e84689c3c2?d=identicon&s=25 Arch Stanton (d6veteran)
on 2006-04-04 18:47
James Ludlow wrote:
> On 4/4/06, Arch Stanton <d6veteran@gmail.com> wrote:
>> Maybe I misunderstand the parameterization of find(), I am getting this
>> syntax error for
>> <% @choices = Choic
>> e.find(:all, :conditions => "question_id" = question.id, :order =>
>> "order") %>
>
> It looks like your conditions are messed up.
>
> :conditions => ["question_id = ?", question.id]
>
> -- James


Ahh I get it thanks!
This topic is locked and can not be replied to.