我不明白为什么这会给我一个错误
<%= form_for(@user), :html => {:class => 'form-connexion'} do |f| %>
<%= render 'shared/error_messages' %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation, "Confirm Password" %>
<%= f.password_field :password_confirmation %>
<%= f.submit "Save changes", class: "btn btn-large btn-primary" %>
<% end %>
D:/xxxxxxx/app/views/users/edit.html.erb:7: syntax error, unexpected =>, expecting keyword_end ...end= form_for(@user), :html => {:class => 'form-connexion'}... ... ^
D:/xxxxxxx/app/views/users/edit.html.erb:7: syntax error, unexpected keyword_do_block, expecting keyword_end ...{:class => 'form-connexion'} do |f| @output_buffer.safe_appe... ... ^
D:/xxxxxxx/app/views/users/edit.html.erb:29: syntax error, unexpected keyword_ensure, expecting end-of-input
我在另一个文件中使用相同的语法,但没关系。
答案 0 :(得分:3)
form_for(@user), :html => ...
该结束括号在@user
之后关闭方法#form_for
的调用,因此它不知道如何处理逗号,然后是哈希。
将其更改为:
form_for(@user, :html => ...) do |f|
你会好的。甚至没有括号:
form_for @user, :html => ... do |f|