HABTM does have its use. If your domain does not need any attributes other than the foreign keys of the tables that are connected then HABTM is good enough. In this case the association class is just a join table.
When your application demands that other attributes needs to be persisted that belongs to the association class then you have to go for the has_many :through relationship.
I have the following tables/objects…
class Currency < ActiveRecord::Base has_many :product_prices
has_many :products, :through => :product_prices end
class Product < ActiveRecord::Base has_many :product_prices has_many :currencies, :through => :product_prices end
class ProductPrice < ActiveRecord::Base
belongs_to :product belongs_to :currency end
Is that the correct configuration for what is effectivly a HABTM relationship? If not could somone please point me in the right direction!!
This is correct.
Furthermore, if i wanted to submit data into the product prices table/object, how would i do that? The same was as any other commit?
Object.new(params[:object]) ?
When a product is associated to the currency, you can do:
product_price = ProductPrice.new
product_price.attribute1 = params[:attribute1]
and so on.