2011-05-16 84 views
1

已經看瑞安的優秀的截屏並在此事件(#263 client_side_validations),他說,以添加以下代碼行中_form.html.erb文件:Rails3中客戶端驗證問題

<%= form_for @user, :validate => true do |f| %> 

然而,如果用戶有安裝設計,他們將會把該代碼放到哪裏下面的代碼已經被安裝在它創建一個錯誤頂部new.html.erb文件:

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name))  do |f| %> 

如何得到這個工作任何想法?

的SyntaxError在設計/註冊#新

/app/views/devise/registrations/new.html.erb where line #4 raised: 

compile error 
/app/views/devise/registrations/new.html.erb:4: syntax error, unexpected tIDENTIFIER, expecting kEND 
...tion_path(resource_name)) user, validate => do |f| @output_b... 
         ^
app/views/devise/registrations/new.html.erb:4: syntax error, unexpected tASSOC, expecting '=' 
...ource_name)) user, validate => do |f| @output_buffer.safe_co... 
         ^
app/views/devise/registrations/new.html.erb:26: syntax error, unexpected kENSURE, expecting $end 
Extracted source (around line #4): 

1: 
2: <h2>Sign Up</h2> 
3: 
4: <%= form_for (resource, :as => resource_name, :url => registration_path(resource_name)) user, validate => do |f| %> 
5: <%= devise_error_messages! %> 
6: 
7: <p><%= f.label :username %><br /> 

THX。

回答

2

試試這個:

<%= form_for(resource, :validate => true, :as => resource_name, :url => registration_path(resource_name))  do |f| %> 
+0

謝謝 - 完美的作品! – ubique 2011-05-17 23:24:34