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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:13:24+00:00 2026-06-08T04:13:24+00:00

I have a many to many :through association in my rails application between ‘User’

  • 0

I have a many to many :through association in my rails application between ‘User’ and ‘List’ model objects.

#user.rb
class User < ActiveRecord::Base
  attr_accessible :email, :password, :username
  has_many :user_lists
  has_many :lists, :through => :user_lists                                          
end

#list.rb
class List < ActiveRecord::Base
  has_many :user_lists
  has_many :users, through => :user_lists
  attr_accessible :description, :title
end

#userlist.rb
class UserList < ActiveRecord::Base
    belongs_to :user
    belongs_to :list
end

In the console if I attempt to select all the lists (User.first.lists) from a user I get the following error:

NameError: uninitialized constant User::UserList

I’m new to rails. I’m guessing I have something named wrong. Table names are as follows users, lists, user_lists

Can someone tell me what I have wrong here?

  • 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-08T04:13:25+00:00Added an answer on June 8, 2026 at 4:13 am

    Rails magic will look for UserList in app/models/user_list.rb, not app/models/userlist.rb.

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

Sidebar

Related Questions

I have this rails model association (has_many :through) class User < ActiveRecord::Base has_many :assignments
I have Product model and it has many categories with a has_many :through association
I have a rails project where project model has many issues. class Project <
I have the following model, Purchase, on my Rails app: class Purchase < ActiveRecord::Base
I have a has_many through association setup between a song model and an artist
I have the following :has_many, :through association for my models: Group Model: has_many :group_users
I have a many-to-many relationship like this: A user has_many organizations through affiliations and
I have Lineup and Piece models joined by piece_lineup model (has many through). I
In my Rails application, I have a variety of database tables that contain user
I have a standard many-to-many relationship between users and roles in my Rails app:

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.