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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:29:23+00:00 2026-05-23T09:29:23+00:00

Newbie rails developer here. I’m having an issue trying to setup some very simple

  • 0

Newbie rails developer here.

I’m having an issue trying to setup some very simple database associations in a new rails project.

In my database I have two tables, one called “Games” and one called “Onlines”. Here’s what’s in them right now

Game.first
#<Game id: 1, name: "Game 1", description: "This is a cool game", url: "http://domain.com">

Online.first
#<Online id: 1, game_id: 1, now: 222>  

I’m trying to setup a simple association so I can grab the number of users online by doing something like…

Game.find(1).onlines.now 

In my game.rb and online.rb models I have

belongs_to :online 

and

belongs_to :games

accordingly.

When I try and run Game.find(1).onlines.now in the rails console I get the following error.

NoMethodError: undefined method `onlines' for #<Game:0x00000101654300>
from /Users/Jon/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/activemodel-3.0.6/lib/active_model/attribute_methods.rb:367:in `method_missing'
from /Users/Jon/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/activerecord-3.0.6/lib/active_record/attribute_methods.rb:46:in `method_missing'
from (irb):5
from /Users/Jon/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.6/lib/rails/commands/console.rb:44:in `start'
from /Users/Jon/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.6/lib/rails/commands/console.rb:8:in `start'
from /Users/Jon/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.6/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

Am I missing something ridiculously obvious here? I’ve tried everything I can think of.

  • 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-23T09:29:24+00:00Added an answer on May 23, 2026 at 9:29 am

    You should have

    has_many :onlines

    in your Game model, not belongs_to.

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

Sidebar

Related Questions

Rails newbie here, trying to get a new controller working. When I try to
I'm a newbie Rails developer who is getting the following error when trying to
Greetings all, newbie to Rails here. I'm currently having issues routing /profile to the
I'm a newbie to rails and am having some difficulty... I have a page
I am a rails newbie and I am trying to create a database schema
I'm a Rails newbie.... Here's what I'm trying to do.... I created a scaffold
A bit of a newbie question on rails associations. I have a Bug model,
Here is one more newbie question: require 'tasks/rails' I saw this line in Rakefile
So this is a newbie rails design question. Lets say I want some of
Rails newbie here. I have a list of items which can have a status

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.