2010-12-08 53 views
0

有时候我一直在头撞墙。不知道为什么我甚至在collection_select()上出现语法错误时,我确信它是正确的。请帮助铁路2.1.1。ROR-语法错误

<%= f.collection_select (:location_id, Location.find(:all), :id, :name, :prompt => true, 
     {:onchange => remote_function(
     :url => {:action => "loc_selected", :controller => "location", 
      :id=> location.id}, 
     :with => "'location_id='+this.value")}) %> 

编译错误

C:/Users/Tau/rails_proj/incident/app/views/events/_general_step.html.erb:35:语法错误,意想不到的 ')',期望tASSOC ...“'location_id ='+ this.value”)})).to_s); _erbout.concat“\ n ...

+0

请格式化您的代码缩进它4个空格。此外,您是否使用haml或erb? – jergason 2010-12-08 22:14:56

回答

1

你缺少周围:prompt => true大括号内。这个参数集合选择的需求是一个哈希表。通过使用{:prompt => true}修复它。

并请格式化你的代码。

+0

非常感谢您的帮助,我对包括ROR和本网站在内的所有内容都很陌生,请原谅我不要格式化我的代码我想在下次我在这个网站上发布问题时这样做,所以你能告诉我你的意思是什么“格式代码”? – Tau 2010-12-13 05:13:44