jacoulter
jacoulter

Reputation: 740

How Do I Pass A Parameter From link_to To A Controller?

Building a project with Rails 3.1

I would like to provide a link in a parent model's show page that passes the parent model's id to a child object controller's create method.

I'm guessing this will require a custom route, but have no idea how to build it.

Is this possible? Or would I be breaking a Rails convention? I don't want to use a multiple model form if I can avoid it.

Thanks!

Upvotes: 1

Views: 273

Answers (1)

sethvargo
sethvargo

Reputation: 26997

You can just pass them in as arbitrary values:

link_to my_path(:extra_attribute => value, :foo => 'bar')

Upvotes: 2

Related Questions