You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Associations between ActiveResource and ActiveRecord #292
Is there a way to create associations between ActiveResource models and ActiveRecord ones?
I tried to add a belongs_to association and I got the following error:
NoMethodError (undefined method `arel_table' for Project:Class)
@rafaelfranca I can easily define methods on local resources in order to be able to load remote ones, but then I have N+1 query problems when working with collections.
Example: a collection of local resources (AR), each one belonging to a remote one (ARes)
How would you avoid this?
Many thanks,
Mauro
Reacted by Josh Mostafa, adilw3nomad and Erik Nummela
I created a PR that demonstrated a potential implementation for a belongs_to_resource relationship. This could also be pulled out into a stand alone gem or left as a module that does not patch ActiveRecord upon initialization. #393
Activity
rafaelfranca commentedon May 22, 2018
No. There is no way to create Active Record associations between models that are not Active Record models.
mauro-ni commentedon Jun 25, 2018
@rafaelfranca I can easily define methods on local resources in order to be able to load remote ones, but then I have N+1 query problems when working with collections.
Example: a collection of local resources (AR), each one belonging to a remote one (ARes)
How would you avoid this?
Many thanks,
Mauro
basicBrogrammer commentedon Jun 6, 2023
I created a PR that demonstrated a potential implementation for a
belongs_to_resourcerelationship. This could also be pulled out into a stand alone gem or left as a module that does not patch ActiveRecord upon initialization. #393Add join model for groups and forms
Add join model for groups and forms
Add join model for groups and forms
Add join model for groups and forms
Add join model for groups and forms