Derek
Derek

Reputation: 9943

Rails 3: Link_to list item?

I have some buttons which are basically overridden <li>s with CSS. I want to link the entire <li> link to a Rails action.

So I don't want to do this:

<li><%= link_to choice, { :action => "update", :id => @id, :response => index }, :remote => true %></li>

I want to do something like this:

<%= link_to <li>choice</li>, { :action => "update", :id => @id, :response => index }, :remote => true %>

Upvotes: 4

Views: 4199

Answers (2)

ShiningRay
ShiningRay

Reputation: 1008

use block

<%= link_to {...} do %>
  <li>choice</li>
<% end %>

note that rails 3.x uses <%= but rails 2.x uses <%

Upvotes: 8

Abhishek Shukla
Abhishek Shukla

Reputation: 72

use html_safe

<%= link_to "<li>choice</li>".html_safe, { :action => "update", :id => @id, :response => index }, :remote => true %>

Upvotes: 3

Related Questions