Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8229697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:53:08+00:00 2026-06-07T16:53:08+00:00

I have custom controller action for activating a new customer acount in a webshop.

  • 0

I have custom controller action for activating a new customer acount in a webshop. I have a model called customer.rb. The model generates a key and sends the customer an activation link. The link is routed to the customers_controller.rb and the following action:

def activate_customer
  @customer = Customer.find(params[:customer_id])
    if @customer.present?
     if @customer.activation_key == params[:activation_key]
       @customer.activated = true
       @customer.save
       redirect_to :cart
     else
       redirect_to :root
     end
    else
     redirect_to :root
    end
end

I first tried it without @customer.save but the record did not update. I have raised before and after @customer.activated = true and it all seems fine. The only problem is that the record does does not update. I also checked a possible attar_accessible problem, but that’s not it (I shut of attr_accessible entirely to check). Any ideas? Thanx in advance!

*Edit: checked value of @customer.save, returns false…

*Edit:

The problem seems to be the password validation on the Customer model. The validations look as follows:

# Validations
validates_presence_of :title, :country, :zipcode, :city, :street, :number, :first name, :lastname
validates :email, :presence => true, :uniqueness => true, :email => true
validates_confirmation_of :password, :unless => :validate?
validates_presence_of :password

Any ideas how to skip validations on this specific controller action? Thanx for thinking with me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:53:10+00:00Added an answer on June 7, 2026 at 4:53 pm

    You can use conditional validation which is the best practice in this case.

    Here is a railscast on that http://railscasts.com/episodes/41-conditional-validations

    You can then use some code like this:

    attr_accessor :updating_password
    
    validates_confirmation_of :password, :if => should_validate_password?
    
    def should_validate_password?
      updating_password
    end
    

    You then need to set updating_password to false if you want to skip validation.

    @customer.updating_password = false
    @customer.save
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom controller action as listed below. I have a form with
I have a segue (called ToSettingsSegue ) that pushes a custom view controller (
So, I have implemented custom routing in mysite. routes.MapRoute( WithFriendlyNameOnly, {friendlyName}, new { controller
i have a MVC controller called MyController with an action called MyAction. For other
Let's say I have a controller action defined as: public ActionResult(MyModel model, string someParameter)
I have a controller and action which I'm accessing through a custom URL. The
I hate the codeigniter custom urls where it's: domain.com/controller/action/id How can I have it
I have a custom UINavigationController that draws a custom background. That navigation controller is
I have a table view controller with custom cells. In those cells i added
I have a module in which I created a custom page with controller and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.