Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

button_tag like link_to rails 3

I need use this code:

<%= button_tag :class => "btn btn-primary" do %>
 <%= t('.follow_all')%>
<% end %>

html output:

<button class="btn btn-primary" name="button" type="submit">
 Follow all
</button>

if it's possible, How can I use this button like a link, something like:

<%= button_tag new_user_registration_path, :class => "btn btn-primary" do %>
     <%= t('.follow_all')%>
    <% end %>

I need use button_tag helper. I can not use link_to helper, or instead, if it's possible, How can I send params from button without use a form?

like image 980
hyperrjas Avatar asked Jun 24 '12 16:06

hyperrjas


2 Answers

What about this:

<%= button_tag(:type => 'button') do %>
  <% link_to t('.follow_all'), new_user_registration_path %>
<% end %>
like image 187
Nobita Avatar answered Oct 14 '22 16:10

Nobita


Use button_to: http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to

like image 23
Oscar Del Ben Avatar answered Oct 14 '22 17:10

Oscar Del Ben