Rails3 Client Side Validation Issue
Have been watching Ryan's excellent screencasts and on this episode (#263 client_side_validations) he says to add the following line of code in the _form.html.erb file:
<%= form_for @user, :validate => true do |f| %>
However, if users have Devise installed they will be putting the code into the new.html.erb file where the following code is already installed at the top which creates an error:
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
Any ideas on how to get this working?
SyntaxError in Devise/registrations#new
/app/views/devise/registrations/new.html.erb where line #4 raised:
compile error开发者_Go百科
/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.
Try this:
<%= form_for(resource, :validate => true, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
精彩评论