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 7686073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:23:48+00:00 2026-05-31T19:23:48+00:00

Ive got the following problem. I have a model called user which has a

  • 0

Ive got the following problem. I have a model called user which has a column named activated. Im trying to update that value whith the method activated?, but it gives me the error: Validation failed: Password can’t be blank, Password is too short (minimum is 6 characters) Which doesnt make sense to me, because im not touching the password field! I just want to update the activated column. Im putting here the code I think its relevant, but if you think you need more just ask 🙂
Thank you very much in advance!

Model:

attr_accessor :password
attr_accessible :name, :email, :password, :password_confirmation, :activated
has_many :sucu_votes

email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i

validates :name,  :presence => true,
                                    :length => { :maximum => 50 }

validates :email, :presence => true,
                                    :format => {:with => email_regex},
                                    :uniqueness => { :case_sensitive => false }

validates :password, :presence => true,
                                         :length => { :within => 6..15 },
                                         :confirmation => true

before_save :encrypt_password

def activated?
    self.update_attributes!(:activated => true)
    return self.activated
end

Controller from which the method activated? is called

def activate
if request.get?
        user=User.find_by_id(params[:id])
        if user.activated?
            flash[:notice]="Your account has been activated"
            #redirect_to :controller => 'sessions', :action => 'new'
        else
            flash[:error]="We couldnt activate the account"
            redirect_to :controller => 'sessions', :action => 'new'
        end
    end
end
  • 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-05-31T19:23:49+00:00Added an answer on May 31, 2026 at 7:23 pm

    Two things, first the ruby convention is to use predicate methods to return true or false only and not to do anything more like update a record. That is not causing your problem but is a deviation from what other programmers would expect. Secondly, instead of calling update_attributes try just calling:

    update_attribute(:activated, true)

    This should skip the rest of the callbacks for the record

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following problem: I have two tables: (simplified) +--------+ +-----------+ | User
I've got following problem: (c#) There is some class (IRC bot), which has method,
Ive got the following code which I hacked together from website examples. It works
I've got a model creation form in rails which I also have returning JSON
I have the following problem: I've got an entity class 'TEntity' and a mesh
I'm using JSF 2.0 and Glassfish 3.1 and have the following problem: I've got
I have a model called 'BusinessPage' which can be associated with 1 or more
In my Core Data model, I've got a relationship called listItems which links to
Situation Consider I've got the following class structure: // a user model class UserModel
Ive got the following html setup: <div id=div1> <div id=content1>blaat</div> <div id=content1>blaat2</div> </div> it

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.