ActiveRecord::RecordNotSaved - Failed to save the new association Authentication

What does this line say? (We don't see line numbers in the code you posted here.) What happens if you change save to save! near here, so that any errors are flagged immediately? An invalid record will not save, so what are the errors on that object?

Walter

Line 49 is the last line given in my CustomersController code. (--->LINE
49)

The problem is that there isn't a save, but I am just connecting the
authentication to my customers authentication association.

I can't do the save! because of that...

Ah, then you probably missed an end somewhere.

Walter

Solution

Solution
--------
Because of the hashing of my password, it validated the wrong length.
Now I made sure that my validation was performed before I hashed my
password.

NEW PROBLEM (damn it's still tricky for me)
-------------------------------------------

--------------------
Stating the problem:
--------------------

Trying to validate my email with a conformation, but not working at all
(but if I do save! it sends me the :

Validation failed: Email doesn't match confirmation

What I am expecting. But unfortunately I don't get the error in my
form...

--------------------
My code:
--------------------

CustomersController
*******************
@dbCustomer.email = @customer.email
@dbCustomer.email_confirmation = @customer.email_confirmation

unless @dbCustomer.save #on save! -> Validation failed. Email doesn't
match
   render :action => :edit, :notice => "Hello!"
   return
end

edit.html.erb
*************
<% if @customer && @customer.is_signup == false %>
<h2>Please submit your personal password:</h2>
<%= render 'firstLoginForm'%>
<% else @customer = Customer.new %>
<h2>Please sign up to access the customer portal</h2>
<%= render 'signUpForm'%>
<% end %>

_firstLoginForm
***************
<%= form_for @customer do |f| %>
<% if @customer.errors.any? %>
   <div class="form_errors">
     <ul>
       <% @customer.errors.full_messages.each do |msg| %>
         <li>
           <%= msg %>
         </li>
       <%end%>

     </ul>
   </div>
<% end %>
<%= fields_for :authentication do |a| %>
   <%= a.label :password %>
   <%= a.password_field :password %>
   <br />
   <%= a.label :password_confirmation%>
   <%= a.password_field :password_confirmation %>
<% end %>
<br />
<%= f.submit "Save your changes"%>
<% end %>

_signUpForm.html.erb
********************
<%= form_for @customer do |c|%>
   <% if @customer.errors.any? %>
   <div id="form_errors">
     <ul>
       <% @customer.errors.full_messages.each do |msg| %>
         <li>
           <%= msg %>
         </li>
       <%end%>
     </ul>
   </div>
<% end %>
   <p>
     <%= c.label :id%>
     <%= c.text_field :id%>
   </p>
   <p>
     <%= c.label :name %>
     <%= c.text_field :name%>
   </p>
   <h3>Please ad a valid e-mail to receive your credentials:</h3>
   <p>
     <%= c.label :email%>
     <%= c.text_field :email%>
   </p>
   <p>
     <%= c.label :email_confirmation %>
     <%= c.text_field :email_confirmation %>
   </p>
   <p class="button">
     <%= c.submit%>
   </p>
<% end %>

---------------------
The exact error:
---------------------

THERE IS NO ERROR (and that is the problem)

What's in your model? Do you have validates_confirmation_of :email in there somewhere?

Walter

Sorry, did not include that one...

  validates :email, :presence => true, :confirmation => true, :format =>
{:with => /\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\z/}

Thats what is in my Customer validation