Questions tagged [has-and-belongs-to-many]

A has_many :through association set up a many-to-many connection with another model.

In Ruby on Rails, a has_many :through association is often used to set up a many-to-many connection with another model. This association indicates that the declaring model can be matched with zero or more instances of another model by proceeding through a third model.

1372 questions
-1
votes
2 answers

How to save HABTM association in CakePhp?

I have a Product model and an Image model. They have an HABTM association. Some Images exist but they are not linked to the product. Now when I save a Product I would like to link it to some unlinked images using an array of images IDs (I MUST use…
Thiezar
  • 1,143
  • 2
  • 10
  • 16
-1
votes
1 answer

How to get records from has_and_belongs_to_many

I have two models Hotel and Theme and I have applied has_and_belongs_to_many association on it. My migration is class CreateHotelsThemesTable < ActiveRecord::Migration def up create_table :hotels_themes, :id => false do |t| …
-2
votes
2 answers

how can I include multiple values to has and belongs to many relation from various select box?

I have two tables items and sub_category and I have has_and_belongs_to_many relation between two. I have to select values for sub categories from different select boxes and include all those values to the item subcategory. I have a form where I have…
logesh
  • 2,572
  • 4
  • 33
  • 60
-3
votes
1 answer

Updating multiple HABTM relationships in CakePHP

In the Cake cookbook, all the examples seem to use save()/saveAll() to update HABTM relationships for a single record at a time. However, I'd like to create many to many associations using a single call. For example, I have 3 concert events, and I…
Lèse majesté
  • 7,923
  • 2
  • 33
  • 44
-4
votes
2 answers

Will it be an issue if I create a model in rails for the join table that was created through habtm?

Consider the following: I have a model Tags and Post. There is a habtm relationship created such that I have models_tags table created. Will it cause a problem if I create a model for the join table(models_tags)?
1 2 3
91
92