Obviously, I am new to this.
I need to make a link using rails to something within the model. The code I have is this. It is probably not even the correct syntax:
<li id="nav_home"><%= link_to 'SOMETHING', {:controller => 'inventories', :action => 'home'} %></li>
This code defaults to creating a text link, but I want the link element to link. Ideally it would output as so:
<li><a href="goes-to-something"></a></li>
Thanks!
The routing module provides URL rewriting in native Ruby. It's a way to redirect incoming requests to controllers and actions. It replaces the mod_rewrite rules. Best of all, Rails' Routing works with any web server.
The whole point of link_to
is that it helps you create links to resources within your application via your routes. If all you want is <li><a href="#"></a></li>
, then just use <li><a href="#"></a></li>
--- no need to involve link_to.
<li><%= link_to '', '#' %></li>
But that's a bit nutty. Plain HTML is fine. Or there is link_to_function
which will create a link like that but have an onclick
that executes some javascript.
Or you can call other helpers in place of your "SOMETHING"
<li><%= link_to image_tag('foo.png'), '#' %></li>
Renders:
<li><a href="#"><img src="/images/foo.png"/></a></li>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With