has-many-through Questions

3

Solved

How can I make a has_many through work with multiple database connections? I have a database named "master" that holds the location information. That is updated from a separate application. Users...
Serbocroatian asked 28/11, 2011 at 21:20

2

Solved

How to query for Companies with a certain Branch in a "has_many :through" relationship? #company.rb has_many :branch_choices has_many :branches, :through => :branch_choices "Find all compa...
Lungan asked 31/7, 2011 at 16:59

7

Solved

Can someone tell me if I'm just going about the setup the wrong way? I have the following models that have has_many.through associations: class Listing < ActiveRecord::Base attr_accessible .....
Hatband asked 5/8, 2011 at 22:30

9

Solved

How can I achieve the following? I have two models (blogs and readers) and a JOIN table that will allow me to have an N:M relationship between them: class Blog < ActiveRecord::Base has_many :b...
Papillose asked 24/11, 2008 at 22:56

3

Solved

Original question Two resources: users and animals. When creating a user, the client selects check boxes to say how many animals they have. When the user form is submitted, it should not only cr...
Huxley asked 26/3, 2015 at 13:54

6

Solved

I have the following three models (massively simplified): class A < ActiveRecord::Base has_many :bs has_many :cs, :through => :bs end class B < ActiveRecord::Base belongs_to :a has_m...
Hortenciahortensa asked 16/8, 2013 at 8:21

4

I have a Subscriber model // Subscriber Model id user_id subscribable_id subscribable_type public function user() { return $this->belongsTo('App\User'); } public function subscribable() { r...
Blowfish asked 7/4, 2017 at 19:29

4

Solved

I have a Task model associated to a Project model via has_many through and need to manipulate the data before delete/insert via the association. Since "Automatic deletion of join models is dir...
Bloodhound asked 15/5, 2012 at 9:30

1

Solved

I've found a bunch of articles, stackoverflow answers and rails documentation about 'source:', but none of it explains this association in a way I can understand it. I need the most simplified expl...

4

Solved

I'm new to testing and rails but i'm trying to get my TDD process down properly. I was wondering if you use any sort of paradigm for testing has_many :through relationships? (or just has_many in ...
Sarcenet asked 19/10, 2010 at 23:50

5

Solved

Greetings, I have an application where Companies and Users need to belong to each other through a CompanyMembership model, which contains extra information about the membership (specifically, whet...
Ecclesiastic asked 20/9, 2010 at 16:52

3

I get confuse now, I don't know how to delete/destroy a record in a join table: class Task < ActiveRecord::Base belongs_to :schema belongs_to :to_do end class Todo < ActiveRecord::Base ...
Frisky asked 30/8, 2010 at 23:41

2

Solved

I'm new to rails and I've been trying to get two has_many :though relationships to work out (as opposed to using has_and_belongs_to_many as explained by this post http://blog.flatironschool.com/pos...
Lias asked 8/4, 2013 at 17:31

3

Solved

Just ran into an issue with a has_many :through association and after/before-destroy callbacks not being triggered. Say, I have users, groups, and an intermediate relation called membership. I ha...
Salleysalli asked 16/12, 2010 at 21:38

8

Given the following AR models, I would like to sort users alphabetically by last name when given a handle to a task: #user has_many :assignments has_many :tasks, :through => :assignments #ass...
Anselma asked 5/2, 2010 at 7:26

1

I have a user model and role model, connected in ActiveRecord by: has_many roles, through: :role_accounts I want to have an "Edit User" screen that has a list of checkboxes, one for each role. U...
Bride asked 27/4, 2016 at 20:52

3

Solved

i have three models, all for a has_many :through relationship. They look like this: class Company < ActiveRecord::Base has_many :company_users, dependent: :destroy has_many :users, through: ...
Marianelamariani asked 19/2, 2012 at 2:52

6

Solved

I've got a RoR project in the works. Here are the applicable sections of my models. Home has_many :communities, :through => :availabilities has_many :availabilities, :order => "price ASC" ...
Zippora asked 8/2, 2012 at 16:43

1

Solved

Upgrading an app from Rails 4.2.9 to Rails 5.2.1. Through much of the nasty part updating dependencies & whatnot and finally have app running in the console and now trying to hit pages on serv...

2

In my Laravel application I have the following classes: class Product extends Model { public function extended() { return $this->morphTo(); } public function users { return $this->bel...
Scabrous asked 14/4, 2016 at 18:14

2

I have four Models: User Client Store Opportunity The relationships are defined as such: User hasMany Client Client hasMany Store Store hasMany Opportunity User hasManyThrough Store, Client (...
Lochia asked 19/9, 2014 at 16:4

1

Already a month trying to solve the problem at first sight is not very complicated: There are 3 models - team, user and team_user (has_namy: through) In the form of edit and new team to do the abil...
Cleodel asked 4/12, 2016 at 15:48

4

Solved

Right. This simply refuses to work. Been at this for hours. album model class Album < ActiveRecord::Base has_many :features, through: :join_table1 end features model class Feature < Act...
Nightshade asked 24/9, 2013 at 10:7

2

I am stuck. I've been trying to figure out how to include the association changes (has_many, has_many through) on a model that has papertrail. I would like to call MyModel.versions.first.changeset ...

3

I have problems with getting a has_many through association to work. I keep getting this exception: Article.find(1).warehouses.build ActiveRecord::HasManyThroughAssociationNotFoundError: Could no...
Bulbul asked 3/6, 2009 at 10:52

© 2022 - 2025 — McMap. All rights reserved.