providence
providence

Reputation: 29463

ID from Controller#show

I would like to retrieve the id of the current item in a Controller#show page. How is this done? I can't seem to figure this out or find it anywhere.

Upvotes: 0

Views: 71

Answers (1)

jonnii
jonnii

Reputation: 28312

You're probably looking for:

<%= params[:id] %>

There are lots of things wrong with doing this, one of which is it can open you up to CSRF attacks. Make sure to escape your output (this is done automatically in rails 3.)

Upvotes: 1

Related Questions