Troubles getting :id

im using
<%= button_to 'Rent', :controller => 'transaction' , :action => 'rent',
:id => @product.id %>

on ProductsController to pass an :id to a TransactionController

but when searching for the product's id

  def load_product
    @product = Product.find(:id).id
  end
i get Couldn't find Product with ID=id Error
i tried using @product = Product.find(1).id for testint an worked, also,
the URL is ok

transaction/rent/1
controller/action/id

BTW, how can i turn that button_to onto a link_to that works with an
action outside self controller

im using
<%= button_to 'Rent', :controller => 'transaction' , :action => 'rent',
:id => @product.id %>

on ProductsController to pass an :id to a TransactionController

but when searching for the product's id

def load_product
@product = Product.find(:id).id

Did you mean find(params[:id])? Also why have you got .id on the end,
that means it will find the product (once that bit is working), look
up the id and save it in @product. I would have expected to see just
@product = Product.find(params[:id])

BTW, how can i turn that button_to onto a link_to that works with an
action outside self controller

Just specify the controller in the link as you have done for the
button. If the code you have shown is in the transaction
controller/view then you do not need to specify the controller. Also
have a look at the rails guide on Routes to see more sophisticated
ways of specifying paths in links.

On a side note it is arguably better not to put two questions in one
message. The two sets of replies will get mixed up in the thread and
can be difficult to follow.

Colin

wow, that was easy to fix. it's ".id" cause i need just the product ID
thanks for your help and advice

Please quote previous message when replying, it makes it easier to
follow the thread. I presume the fix was to use param[:id]. If all
you need is the id itself why are you bothering to say Find the record
with id params[:id] and then take the id of it? Why not just use
params[:id] in the first place?

Colin

Colin Law wrote in post #962926:

Sorry, that sentence makes no sense to me at all.

Colin