Rails 3: Link to list item?

I have a few buttons that are mostly overridden by <li> using CSS. I want to link the entire <li> link to a Rails action.

Therefore, I do not 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 %> 
+4
source share
2 answers

use html_safe

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

use block

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

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

+8
source

Source: https://habr.com/ru/post/1382643/


All Articles