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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:38:41+00:00 2026-05-14T05:38:41+00:00

Hi im making a small site to help me and friends learn languages. Typical

  • 0

Hi im making a small site to help me and friends learn languages.
Typical use:

Adam is english but is learning japanese.
Adam can practice his japanese by writing and submitting articles written in japanese.
Adam cant (not allowed to) submit any articles written in his native language.
Adam can read articles (written in English) by other users who are learning English

Im trying to think how to model this and its proving to be more difficult than the standard rails has many belongs to associations that I`m accustomed to.

Ill need functionality like

-show all articles written in adams native language
@adam.native_language.articles

-show all posts written by users just like adam (i.e. learning the same language)
@adam.foreign_language.articles

-perhaps showing all posts written by language learners in one particular language
@language => Japanese
@langauge.posts

I need a user, article and language model. But how do i associate the language and user models? It feels like language should be associated twice to the user model, once for native_language and once for foreign_language.

  • 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-14T05:38:42+00:00Added an answer on May 14, 2026 at 5:38 am

    Yeah, you’re right. The association between User and Language is twofold. It’s quite easy to model this situation using Rails:

    class Language < AR::Base
      has_many :native_speakers, :class_name => "User", :foreign_key => "native_language_id"
      has_many :second_language_speakers, :class_name => "User", :foreign_key => "second_language_id"
      has_many :articles
    end
    
    class User < AR::Base
      # we expect the users table to have native_language_id and second_language_id columns
      belongs_to :native_language, :class_name => "Language"
      belongs_to :second_language, :class_name => "Language"
      has_many :second_language_articles, :through => :second_language, :source => :articles
      has_many :native_language_articles, :through => :native_language, :source => :articles
    end
    
    class Article < AR::Base
      belongs_to :language
    end
    

    Something like that should work.

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

Sidebar

Related Questions

I'm making a small quiz-application in Flash (and ActionScript 3). Decided to use the
I'm making a small tool application that user can minimize in the taskbar .
I am going to be making a small user system but I have questions.
im making a small site And Instead of having a header.php and a footer.php
Im making a (small) site in php & mysql. The mysql database consists of
I have just started making a wp-site . I have a small problem with
So I am making a small site using cakephp, and my ACL is set
I'm making a small site where if you click on the background, you get
I have a small problem. I am making a site that has Tags and
We are making a small download site for software we create on AppEngine. We

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.