Controller.controller_name for the controller name. But how

Hi everyone,

To display the current controller name in a view template you can write
<%= controller.controller_name %>.
How do you write if you want to display the current ID parameter in a
URL like this /pages/show/1?

Many thanks for any answer!

-G

To display the current controller name in a view template you can write
<%= controller.controller_name %>.
How do you write if you want to display the current ID parameter in a
URL like this /pages/show/1?

<%= params[:id] %>

Assuming that’s what you called it in your route.

Ahh, that was easy, thanks!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs