# Current selected menu element?

**URL:** <https://www.ruby-forum.com/t/current-selected-menu-element/181170>\
**Category:** Rails\
**Created:** [January 6, 2010, 8:31pm UTC](https://www.ruby-forum.com/t/current-selected-menu-element/181170 "2010-01-06T20:31:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![benol](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bb73d2/32.png) [@benol](https://www.ruby-forum.com/u/benol)\
**Post date:** [January 6, 2010, 8:31pm UTC](https://www.ruby-forum.com/t/current-selected-menu-element/181170/1 "2010-01-06T20:31:19Z")

</div>

Hi,

I am using rails 2.3.4…

Any idea how to implement such thing?:

def secondary\_menu\_link\_to(link\_name, link\_path)  
if (link\_path is the current @controller.controller\_path and  
@controller.action\_name)  
link\_to “&racuo; #{link\_name}”, link\_path  
else  
link\_to link\_name, link\_path  
end  
end

I don’t know how to exactly implement the “if condition”.

I am using RESTful resources, so I don’t use :controller =\> … and  
:action =\> when constructing menu links, I use the REST helper methods.  
sample call of this method in a view:

\<%= secondary\_menu\_link\_to(“Users”, users\_path) -%\>

Thanks!

M.

---

<div class="post-metadata">

**Author:** ![benol](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bb73d2/32.png) [@benol](https://www.ruby-forum.com/u/benol)\
**Post date:** [January 6, 2010, 9:41pm UTC](https://www.ruby-forum.com/t/current-selected-menu-element/181170/2 "2010-01-06T21:41:45Z")

</div>

On Jan 6, 2:31Â pm, Michal B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Â Â else  
> \<%= secondary\_menu\_link\_to(“Users”, users\_path) -%\>
> 
> Thanks!
> 
> ## M.
> 
> Posted viahttp://www.ruby-forum.com/.

Sounds like you want current\_page?

> **[ActionView::Helpers::UrlHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#M001603)**
>
> Provides a set of methods for making links and getting URLs that depend on the routing subsystem (see ActionDispatch::Routing).

[http://www.railsapi.com](http://www.railsapi.com) is a _fantastic_ tool for searching  
documentation when you get stuck like this.
