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

  • Home
  • SEARCH
  • 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 6979171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:51:07+00:00 2026-05-27T17:51:07+00:00

I have 2 models that I am currently testing with. One is the top

  • 0

I have 2 models that I am currently testing with. One is the top level model (Account::User) and the other is an associated model (Account::Profile). I am having some difficulty pulling data from the associated model.

The code below is for Rails 3.1

I am getting the exception:

undefined method profile' for #<Class:0x7fe8aa0674b8>

Currently my models look like this:

Account::User:

class Account::User < ActiveRecord::Base

validates_presence_of :username, :first_name, :last_name, :instance_id, :user_type, :is_active
validates_uniqueness_of :username

has_one :profile, :class_name=> 'Account::Profile'

def self.all_by_user_type(user_type)
  return all :conditions => ["user_type = ?", user_type]
end

def self.all_by_user_status(user_status)
  return all :conditions => ["is_active = ?", user_status]
end

def self.all_by_last_login(last_login)
  return all :conditions => ["last_login between ? and ?", last_login, Date.current]
end

def self.all_by_created_by(created_by)
  return all :conditions => ["created_by = ?", created_by]
end
end

Account::Profile

class Account::Profile < ActiveRecord::Base
   belongs_to :user, :class_name 'Account::User'
end

My controller action looks like this:

def dashboard
    @user = Account::User.profile
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-27T17:51:08+00:00Added an answer on May 27, 2026 at 5:51 pm

    When you write Account::User.profile, you’re trying to access a class method named profile. Now, has_one (and friends) actually sets up the relationship on instances of the class, so you might use it like @user.profile.

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

Sidebar

Related Questions

I currently have a client that wants me to 'abstract' out a domain model
I have four models that are related to one another, the way I have
If I have two models that are guaranteed to have a one-to-one correspondence, i.e.
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
Say that I have two models- Users and Accounts. Each account can have at
I have three models that look something like this: class Bucket < ActiveRecord::Base has_many
I have a few models that need to have custom find conditions placed on
I have a number of models that store words as a string with each
I have methods in all of my models that look like this: def formatted_start_date
I have quite a few libraries and models that get loaded into a controller,

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.