HABTM example required

Hi

I am newbie to rails. I am facing some problems with establing an
association in rails. I have two tables namely customer and product.

Table Name: customers, products
HABTM table name: customers_products

class Customer < ActiveRecord
has_and_belongs_to_many :products
end
class Product < ActiveRecord
has_and_belongs_to_many :customers
end

I need to create an interface wherein I will select the customer_id, and
product_id. On submitting, it should enter the details in
customers_products table

Any help would be of great help

Regards

You could do:

@customer = Customer.find_by_name(“Joe Blogs”)
@product = Product.find(1)
@customer.products << @product
@customer.save