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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:16:28+00:00 2026-06-17T23:16:28+00:00

I made such a relationship using this answer: Ruby on Rails has_many through self-referential

  • 0

I made such a relationship using this answer: Ruby on Rails has_many through self-referential following/follower relationships

So I’ve the following Models :

class User < ActiveRecord::Base

  has_many :is_trustings
  has_many :trusted_users, :through => :is_trustings, :source => 'trusted'

  has_many :trusters, :class_name => 'IsTrusting', :foreign_key => 'trusted_id'
  has_many :trusting_users, :through => :trusters, :source => :user

end

&

class IsTrusting < ActiveRecord::Base
  belongs_to :user
  belongs_to :trusted, :class_name => 'User'
end

Everything is okay when using it in console.
Now I would like to make a nested route to allow a client to retrieve an user’s followers.

But It don’t work the way I expect…

See, in my routes.rb I wrote

resources :user do
   resources :is_trusting
   resources :trusted_users
   resources :trusting_users
end

Wich makes routes like this :

/users/:user_id/is_trustings(.:format)       is_trusting#index

I’m okay with this one as it’s the intermediary model

Now I want the embeded modelsn but here is what I get :

/users/:user_id/trusted_users(.:format)       trusted_users#index
/users/:user_id/trusting_users(.:format)      trusting_users#index

This obviously don’t work as there is no TrustedUsersController. I wan’t this routes to go for UserController.

There must be a built-in shortcut like the :class_name => ‘Users’ in Models…

Does somebody know it ? 🙂

  • 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-17T23:16:29+00:00Added an answer on June 17, 2026 at 11:16 pm

    as far as i understood the question you can just use :controller key

    #....
     resources :trusted_users, :controller => :users
    #..
    

    hope you asked for it )

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

Sidebar

Related Questions

Brent's answer suggests me that has made a database of SO questions such that
well, I just made such a hello world non-Flex app in FlashDevelop and packaged
I made a slug with dash for my stories URLs such as: Fetching records
I have a component that is made up of various components such as a
Made this nice little loop for hiding and showing div's, works as a charm
I've created an application through which I need to search using Bing. I installed
I've made such experiment - made 10 million random numbers from C and C#.
I'm using the SonataAdminBundle plus DoctrineORMBundle and let's say I have a Post/Tags relationship
I have a model that has a number of has_many, and has_many :through model
I have made use of the following JPA implementations: Hibernate, Toplink, OpenJPA Each of

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.