I want to pass some parameters with link_to method to create method, so that the form will shown prefilled to a user.
I wrote this code to pass the parameters,
<%= link_to "Buy", new_transaction_url(:friend_id => @friend.id, :t_type => 2) %>
And in transactions_controller's new method, I have:
@transaction = Transaction.new
@transaction.t_type = params[:t_type]
It didn't work as well.
That would be great if you can help me.
Thanks.
Usually new_transaction_url
would call the #new
action in your controller, not the #create
action. Watch your log file while you do it to see exactly what controller action is being called and what parameters are being passed.