Reputation: 5559
I want to use an icon on a Twitter intent button.
<%= button_to "Share on Twitter", "https://twitter.com/intent/tweet?text=#{@twitter_message}", :class => "btn" %>
Is it possible?
There are 2 other buttons on the page using button_tag helpers and I can insert the icons into those buttons. Should I convert the button_to into a button_tag and if so how?
Upvotes: 1
Views: 790
Reputation: 5408
Why to not use link_to
instead, as more suitable for your case.
link_to 'http://tweeter.com/bla-bla', class: 'btn' do
# Your text and icon
end
Upvotes: 1
Reputation: 22296
According to the button_to
documentation, it generates an input tag:
<%= button_to "New", action: "new" %>
<form method="post" action="/controller/new" class="button_to">
<div><input value="New" type="submit" /></div>
</form>"
So you should use link_to instead, with a button class, like:
<%= link_to "Share on Twitter", "https://twitter.com/intent/tweet?text=#{@twitter_message}", :class => "btn icon-edit" %>
I've done this using twitter bootstrap.
Upvotes: 3
Reputation: 3999
This should work:
<%= button_to "https://twitter.com/intent/tweet?text=#{@twitter_message}", :class => "btn" do %>
<i class="icon-something"></i>Share on Twitter
<% end %>
Upvotes: 0