Rails custom controller action does not save -


I have custom controller work to activate a new client acount in a webshop. I have a customer.rb model. The model generates a key and sends an activation link to the customer. The link has been sent to customers_controller.rb and to do the following:

  def activate_customer @customer = customer.find (params [: customer_id]) If @client current ? If @customer.activation_key ============================= Customer Active = correct @ customer Redirect: Cart and otherwise redirect_to: root end else redirect_to: root end end  

I tried it first without @ customer.save but did not update the record I went. I & # 39; d already @clients. Active = true and it all looks fine. Only one problem is that the record does not update. I also probed the possible attar_accessible problem, but that is not (I < Code> attr_accessible is closed to fully check). any idea? Thanx in advance!

* Edit: Checked value of @ customer.save , false back ...

* edit :

Password authentication occurs on the customer model. Consider the assumptions as follows:

  # validates validates_presence_of: title, country ,: zipcode, city ,: street, number :: first name, last name valid: email,: presence = & gt; ; True ,: Specification = & gt; True ,: Email = & gt; True validates_confirmation_of: password, unless:> = & gt; : Valid? Validates_presence_of: password  

Any ideas to leave the assumptions on this specific controller action? Thanx to think with me!

You can use conditional verification which is the best practice in this case. / P>

Here's a RailCags

You can then use some code:

  attr_accessor: updating_password validates_confirmation_of: password ,: if = & gt; ; Should_validate_password? Def should_validate_password? Updating_password end  

If you want to leave the verification, you will need to set up updating_password to do the wrong.

  @ customer.updating_password = false @ Customer. Save  

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -