4

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 %>
Derek
  • 9,773
  • 7
  • 29
  • 34

2 Answers2

8

use block

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

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

ShiningRay
  • 1,008
  • 7
  • 12
  • Quick note: the block format varies depending on the type of construct being used. For example, link_to will use `<%= .. %>`, but if still uses `<% .. %>` – Adam Eberlin Nov 23 '11 at 15:19
3

use html_safe

<%= link_to "<li>choice</li>".html_safe, { :action => "update", :id => @id, :response => index }, :remote => true %>
Conrad Frix
  • 51,984
  • 12
  • 96
  • 155
  • Since answers uses Markdown formatting you need to select your HTML code and then press the `{}` button in order for it to come out right. – Conrad Frix Nov 23 '11 at 06:57