Tik’s Blog

ร้อยแปดพันเก้า

SyntaxError in Community#index ใน RailsSpace

leave a comment »

ตามโค้ดใน Listing 11.1.1 ของ RailsSpace (หน้า 328) เขียนโค้ดแบบนี้

<% form_tag({ :action => "search" }, :method => "get") do %>
  ...
<% end %>

แต่ว่าถ้าเราเขียนตามตัวอย่างใน Rails 2.2 เราจะเจอ error ว่า

SyntaxError in Community#index
Showing app/views/community/_search_form.html.erb where line #1 raised:
compile error
/Users/Tik/temp/rails_space/app/views/community/_search_form.html.erb:1: syntax error, unexpected tASSOC, expecting '}'
...e=true ;  form_tag {:action => "search"}, :method => "get" d...
                              ^
/Users/Tik/temp/rails_space/app/views/community/_search_form.html.erb:1: syntax error, unexpected ',', expecting kEND
...orm_tag {:action => "search"}, :method => "get" do ; @output...

วิธีแก้ก็ง่ายๆ แค่เอา :action ออกจาก hash ก็เรียบร้อย เพราะดูเหมือนว่า Rails 2.2 ไม่ต้องการ hash สำหรับ :action แล้ว

Written by sukita

มีนาคม 17, 2009 ที่ 9:53 pm

บันทึกโพสใน Programming

Tagged with

ใส่ความเห็น