سؤال

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