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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:18:50+00:00 2026-05-29T20:18:50+00:00

So I have an example I came across in some reading where we define

  • 0

So I have an example I came across in some reading where we define in a rails model

has_many :some_tablename

Then later they reference it by saying

if some_tablename.empty?
  #do something
end

I am new to Ruby, so the magic isn’t quite clear to me why I wouldn’t do

if :some_tablename.empty?
  #do something
end

Now, I understand that .empty can be called on a number of types, Symbol not being one of them. So, I am expecting that the answer is going to be something like….the .inspect or .to_s is being called on the symbol :some_tablename (behind the scenes) and returning a string representation which then we’re calling .empty on it.

is that correct, or can someone set me straight of how it is lining up :some_tablename to some_tablename?

  • 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-29T20:18:52+00:00Added an answer on May 29, 2026 at 8:18 pm

    ActiveRecord makes extensive use of Ruby as a metaprogramming language to perform much of the queries you can make over a model.

    When you call if some_table you are calling a some_table method which in fact does’t exists, so the method_missing method of ActiveRecord::Base is called (if your model extends it) and it looks in an attributes hash which is built with your has_many, belongs_to directives and then builds a query over that missing method, specifically an inner join in your case as some_table is a has_many.

    Check http://apidock.com/rails/ActiveRecord/Base/method_missing.

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

Sidebar

Related Questions

In reading up on ASP.NET MVC I came across some wonderful examples of validation
I have been trying to learn Prolog and came across this syntax on some
A friend and I have been playing around with pygame some and came across
I have an example of some code that I see often in websites that
this morning I came across this code, and I have absolutely no idea what
I'm working on a some project in C#, and I came across the following
I've came across a dilemma which I think is worth discussing here. I have
Recently I came across a gcc extension that I have found rather useful: __attribute__(cleanup)
I came across a few articles like this one , which suggest that some
I have been brushing up on my design patterns and came across a thought

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.