我得到這個heroku錯誤,PG ::錯誤:錯誤:WHERE的參數必須是類型布爾值,而不是整數
這些是我的Heroku日誌。
2013-10-15T19:51:45.703129+00:00 app[web.1]: 19: <% cities = SubjectGradeCity.includes(:city).collect(&:city).uniq %>
2013-10-15T19:51:45.703129+00:00 app[web.1]: 20: <% grades = SubjectGradeCity.includes(:grade).where(:city_id).collect {|s| {:name => s.grade.name, :id => s.grade.id}}.uniq %>
2013-10-15T19:51:45.703129+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR: argument of WHERE must be type boolean, not type integer
2013-10-15T19:51:45.703129+00:00 app[web.1]: LINE 1: ...ade_cities".* FROM "subject_grade_cities" WHERE ("subject_g...
2013-10-15T19:51:45.703129+00:00 app[web.1]: ^
2013-10-15T19:51:45.703129+00:00 app[web.1]: 17: <%= simple_form_for :assignments_filter , :html => {:id => "assignments_filter_form"}, :url => {:controller => "requests", :action => "assignments2" } do |f| %>
這是我的代碼中的意見
<% cities = SubjectGradeCity.includes(:city).collect(&:city).uniq %>
<% grades = SubjectGradeCity.includes(:grade).where(:city_id).collect {|s| {:name => s.grade.name, :id => s.grade.id}}.uniq %>
<% subjects = SubjectGradeCity.includes(:subject).where(:city_id).collect {|s| {:name => s.subject.name, :id => s.subject.id}}.uniq %>
<% grades.unshift({:name => "You have to select your city first", :id => ""}) if grades.empty? %>
<% subjects.unshift({:name => "You have to select your city first", :id => ""}) if subjects.empty? %>
幫助,請..
哇,我知道有一個想法。如果我這樣說? <%grades = SubjectGradeCity.includes(:grade).where(:city_id =>:city_id).collect {| s | {:name => s.grade.name,:id => s.grade.id}}。uniq%> <%subject = SubjectGradeCity.includes(:subject).where(:city_id =>:city_id).collect {| S | {:name => s.subject.name,:id => s.subject.id}}。uniq%> – ben
這會工作,但你從哪裏得到:city_id?另外,請參閱包含NickM答案的編輯,這絕對是最佳做法。 –
是的,我同意。非常感謝,它工作。我正在使用表單向控制器提交,我不想使用模型。 – ben