Skip to content

Instantly share code, notes, and snippets.

@RemiBa
Created November 7, 2012 14:23
Show Gist options
  • Save RemiBa/4031894 to your computer and use it in GitHub Desktop.
Save RemiBa/4031894 to your computer and use it in GitHub Desktop.
Form differences
<%= form_for @customer do |c| %>
<% if @customer.errors.any? || @customer.authentication.errors.any? %>
<div class="form_errors">
<ul>
<% if @customer.errors.any? %>
<% @customer.errors.full_messages.each do |msg| %>
<li>
<%= msg %>
</li>
<%end%>
<%end%>
<% if @customer.authentication.errors.any? %>
<% @customer.authentication.errors.full_messages.each do |msg| %>
<li>
<%= msg %>
</li>
<% end %>
<%end %>
</ul>
</div>
<% end %>
<%= c.fields_for :authentication do |builder| %>
<%= builder.label :password%>
<%= builder.password_field :password%>
<br/>
<%= builder.label :password_confirmation %>
<%= builder.password_field :password_confirmation %>
<br/>
<% end %>
<%= c.submit "Save your changes"%>
<% end %>
<h3 id="personaldetails">Personal details</h3>
<table border="0">
<tr>
<td>Current e-mail:</td>
<td><%= @customer.email%></td>
</tr>
</table>
<%= form_for @customer do |c| %>
<% if @customer.errors.any? || @customer.authentication.errors.any? %>
<div class="form_errors">
<ul>
<% if @customer.errors.any? %>
<% @customer.errors.full_messages.each do |msg| %>
<li>
<%= msg %>
</li>
<%end%>
<%end%>
<% if @customer.authentication.errors.any? %>
<% @customer.authentication.errors.full_messages.each do |msg| %>
<li>
<%= msg %>
</li>
<% end %>
<%end %>
</ul>
</div>
<% end %>
<div class="edit email">
<%= c.label :email%>
<%= c.text_field :email, :value => ""%>
<%= c.label :email_confirmation %>
<%= c.text_field :email_confirmation, :value => ""%>
</div>
<%= c.fields_for :authentication do |build| %>
<div class="edit password">
<%= build.label :password %>
<%= build.password_field :password %>
<%= build.label :password_confirmation%>
<%= build.password_field :password_confirmation %>
</div>
<% end %>
<%= c.submit("Edit profile")%>
<% end %>
CHECKING ERROR VALIDATION CHANGEPASSWORD
{"utf8"=>"✓", "_method"=>"put", "authenticity_token"=>"LiCv6shHTr8gXVk/fNPmhGk2pJ2uUM2WmQ0mm0OWeLs=", "customer"=>{"authentication_attributes"=>{"password"=>"qdsfqsdf", "password_confirmation"=>"dfqsd", "id"=>"2"}}, "commit"=>"Save your changes", "action"=>"update", "controller"=>"customers", "id"=>"2110002"}
-> Customer
- authentication_attributes
-password
-password_confirmation
Gives following errors:
Password doesn't match confirmation
Password is too short (minimum is 5 characters)
CHECKING ERROR VALIDATION EDITABLEDETAILS
{"utf8"=>"✓", "_method"=>"put", "authenticity_token"=>"LiCv6shHTr8gXVk/fNPmhGk2pJ2uUM2WmQ0mm0OWeLs=", "customer"=>{"email"=>"[email protected]", "email_confirmation"=>"[email protected]", "authentication_attributes"=>{"password"=>"qsdf", "password_confirmation"=>"f", "id"=>"1"}}, "commit"=>"Edit profile", "action"=>"update", "controller"=>"customers", "id"=>"2110001"}
-> Customer
- email
- email_confirmation
- authentication_attributes
-password
-password_confirmation
Gives following errors:
Authentication password doesn't match confirmation
Authentication password is too short (minimum is 5 characters)
Password doesn't match confirmation
Password is too short (minimum is 5 characters)
CHECKING ERROR VALIDATION CHANGEPASSWORD
{"utf8"=>"✓", "_method"=>"put", "authenticity_token"=>"LiCv6shHTr8gXVk/fNPmhGk2pJ2uUM2WmQ0mm0OWeLs=", "customer"=>{"authentication_attributes"=>{"password"=>"qdsfqsdf", "password_confirmation"=>"dfqsd", "id"=>"2"}}, "commit"=>"Save your changes", "action"=>"update", "controller"=>"customers", "id"=>"2110002"}
-> Customer
- authentication_attributes
-password
-password_confirmation
Gives following errors:
Password doesn't match confirmation
Password is too short (minimum is 5 characters)
CHECKING ERROR VALIDATION EDITABLEDETAILS
{"utf8"=>"✓", "_method"=>"put", "authenticity_token"=>"LiCv6shHTr8gXVk/fNPmhGk2pJ2uUM2WmQ0mm0OWeLs=", "customer"=>{"email"=>"[email protected]", "email_confirmation"=>"[email protected]", "authentication_attributes"=>{"password"=>"qsdf", "password_confirmation"=>"f", "id"=>"1"}}, "commit"=>"Edit profile", "action"=>"update", "controller"=>"customers", "id"=>"2110001"}
-> Customer
- email
- email_confirmation
- authentication_attributes
-password
-password_confirmation
Gives following errors:
Authentication password doesn't match confirmation
Authentication password is too short (minimum is 5 characters)
Password doesn't match confirmation
Password is too short (minimum is 5 characters)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment