Passing :id param in link_to etc...

Hi --

Just need some more inside information...

Sample Code from the AWDWR book.

<%= link_to ( image_tag( product.image_url ),   { :action => :add_to_cart, :id => product },   :method => :post,   :confirm => "Are you sure?" ) %>

Why is my ":id =>" reference using 'product' and not 'product.id'

Is the :id symbol 'dual purpose' and used as a key for an id param AND it also infers that the FIELD to 'get' from the product object is named 'id'?

It uses the to_param method to get the value, so product ends up being product.to_param. By default, to_param returns the id, but you can override it if you wish:

   class Book < ActiveRecord::Base      def to_param        isbn      end    end

for example.

David