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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:30:14+00:00 2026-05-23T00:30:14+00:00

I have a user model and an operator model which belongs to user. I

  • 0

I have a user model and an operator model which belongs to user. I created some factories that associate them(in my feature, a user account is created when an operator signs up) so I made this step:

def create_operator_with_user(operator_name)
  user = Factory(:user)
  puts "MY PASS: #{user.password}"
  operator = Factory(:operator, :chief_pilot_or_business_owner => operator_name, :user_id => user.id)
  pew = User.find(operator.user_id)
  puts "USER: #{operator.user.inspect} PASS: #{operator.user.password} PEWPASS: #{pew.password}"
end

this is my user factory:

Factory.define :admin, :class => User do |f|
  f.sequence(:login)            { |n| "admin#{n}"}
  f.is_admin                    true
  f.password                    "password"
  f.password_confirmation       "password"
  f.sequence(:email)            { |n| "test#{n}@test.com"}
end

Factory.define :user, :parent => :admin do |f|  
  f.sequence(:login)            { |n| "user_#{n}" }
  f.sequence(:email)            { |n| "the_user_#{n}@asdf.com" }
end

I tried to run my feature and here was the output:

MY PASS: password
USER: #<User id: 181, login: "user_1", email: "the_user_1@asdf.com", crypted_password: "e9f6932a07cbe6e49073a331530f9dc01a3482502d25770be00...", password_salt: "YEjT9Q8EGYdrNh4qGZda", persistence_token: "259a61440f6ecd001e79a4aaf1c5c343e50be04388bbf1718c3...", created_at: "2011-06-02 04:24:34", updated_at: "2011-06-02 04:24:34", is_admin: true> 
PASS:  
PEWPASS:

So the question is, the user DOES have a password, since it was allowed to be created, not to mention it printed it out after being created using the factory. Problem is, when I try to access the password via User.find(user.id) or operator.user, why is it that password is blank?

If it helps, this is for authlogic

  • 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-23T00:30:15+00:00Added an answer on May 23, 2026 at 12:30 am

    It seems that I was trying to access a protected attribute of authlogic, that’s why I couldn’t access the password even if I tried getting the user object again. My solution was to use a global variable instead (@user) so I could access it in other steps.

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

Sidebar

Related Questions

I have a user model that has_one profile, and the profile belongs to the
So I have a User model that :has_many other models like Documents, Videos, Posts
I have a model Foo which have a ForeignKey to the User model. Later,
I have a data model that includes common columns like addedBy, editedby (user), addedDate,
I have an Attendance model that allows the user to enter a starting, ending
I have a user model (sql table) that has_one : profile. profiles have user_id
I'm building an app in Rails 3. I currently have a user model which
I have a user model that has_one membership (active at a time). For auditing
I have a user model. In it, I have set validations that are used
I have a User model that has a Roles collection. The Roles collection has

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.