문제

I just recently upgraded a Rails project from Rails 3.0.10 and Ruby 1.8 to Rails 3.2 and Ruby 1.9. However, after the upgrade, one of the views that has never caused me trouble before is now throwing an error. The view code in question is from my index.html.erb.

<%= form_tag ({:controller => 'upload', :action => 'single_content'}, :multipart => true) do |f| %>
    <%= hidden_field 'upload', 'single_content_row_id' %>
    <%= file_field 'upload', 'single_content', :multiple => false, :hidden => 'true' %>
<% end %>

This ran fine before the upgrade, but now I get this.

ActionView::Template::Error (./rails-root/app/views/index/index.html.erb:173: syntax error, unexpected ',', expecting ')'
..., :action => 'single_content'}, :multipart => true) do |f| @...

I get that it is pointing at the comma saying it shouldn't be there, but I don't get why and, possibly more importantly, why does it complain now but not under Rails 3.0.10 and Ruby 1.8?

도움이 되었습니까?

해결책

You have this error because you leave space before bracket with method's parameters. Remove that bracket (or space) and it should be ok:

<%= form_tag {:controller => 'upload', :action => 'single_content'}, :multipart => true do |f| %>

Since this is a syntax error, the reason you get this is language update, not framework update.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top