Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 %>
like image 228
Derek Avatar asked Dec 21 '22 05:12

Derek


2 Answers

use block

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

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

like image 193
ShiningRay Avatar answered Jan 02 '23 09:01

ShiningRay


use html_safe

<%= link_to "<li>choice</li>".html_safe, { :action => "update", :id => @id, :response => index }, :remote => true %>
like image 25
Abhishek Shukla Avatar answered Jan 02 '23 10:01

Abhishek Shukla