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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:19:06+00:00 2026-05-26T13:19:06+00:00

I am a beginner with Ruby on Rails. I have a question regarding organizing

  • 0

I am a beginner with Ruby on Rails. I have a question regarding organizing objects and classes.

I have an Article class that has a few fields, like author, keywords, date, etc.

The problem is that I want to organize these article objects to be able to analyze them collectively. The articles come from different sources and I want to be able to access them based on the source.

I am guessing I can have a new class for ArticleSource and relate it to the Article class through relationships such as has_one or embeds_one. Am I doing this right, or is there a better way?

Thanks in advance!

  • 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-26T13:19:06+00:00Added an answer on May 26, 2026 at 1:19 pm

    I think has_many and belongs_to will do what you want.

    After adding an article_source_id column to the Article table, your classes would look something like this:

    class ArticleSource
      has_many :articles
    end
    
    class Article
      belongs_to :article_source
    end
    

    Then you can analyze the articles collectively using code like this:

    source = ArticleSource.find_by_name("New York Times");
    articles = source.articles
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Absolute beginner question: I have a template file index.html that looks like this: ...
I'm a beginner of Ruby and Rails, so this is probably an easy question.
Brief question, beginner's work on Ruby/Rails. Here's my view: <h1>News</h1> <%= @posts.each do |post|
I am a beginner Ruby on Rails developer. So far I have created several
I have a Ruby on Rails online marketplace that is broken up into categories.
I'm a beginner to ruby on rails that's migrating an access database to RoR.
A few years back, I started learning Ruby/Rails from some beginner's guide for Rails.
I am a beginner at Ruby on Rails. Currently, I have the following problem:
I'm just learning Ruby and have and have an extremely beginner question. Is the

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.