0

I've been using glyphicons with Bootstrap for a few weeks with no problems. However now I'm using link_to with more arguments and I can't put the "do" in the proper place to get things working error free.

I have implemented my basic link_to's like the following example with no problem: How to add glyphicons to rails link_to helper - Bootstrap 3

Here's my code:

<%= link_to("Start Task", task_path(task, "task[started_at]" => DateTime.now), :method => :put, :confirm => "Sure?", class: "btn btn-default btn-sm") %>

I sincerely appreciate any help!

Community
  • 1
  • 1
orky
  • 241
  • 1
  • 4
  • 10

2 Answers2

1

You can use link_to with a block as stated in the link_to documentation

You can use a block as well if your link target is hard to fit into the name parameter.

<%= link_to(task_path(task, "task[started_at]" => DateTime.now), :method => :put, :confirm => "Sure?", class: "btn btn-default btn-sm") do |link| %>
  <i class="glyphicon glyphicon-play"></i> Start Task
<% end %>
Eyeslandic
  • 14,553
  • 13
  • 41
  • 54
0

Found the following link and made the necessary adjustments: Adding a Twitter Bootstrap button icon to button_to in Rails

<%= link_to raw("<i class=\"glyphicon glyphicon-play\"></i> Start"), task_path(task, "task[started_at]" => DateTime.now), :method => :put, :confirm => "Sure?", class: "btn btn-default btn-sm" %>
Community
  • 1
  • 1
orky
  • 241
  • 1
  • 4
  • 10