0

Hi I've installed the Thumbs_up gem and it works great.

But now I want to do a button that does the same as this.

<%= link_to('vote for this post!', vote_up_retailer_path(@retailer), :remote => true, :method => :post) %>

The problem I got is that I want a image and a text inside the button with the text "Like <%= @retailer.title %>", (like youtubes like button).

The button I have is coded like this.`

<button role="button" class="like">
  <img src="/images/layout/blank.gif"><span>Like <%= @retailer.title %></span>
</button>

How can I accomplish the button with these features in rails3?

Thanks in advance,

Philip
  • 6,827
  • 13
  • 75
  • 104

1 Answers1

0

I'm not sure if i understood that correctly, but to add a variable inside your text, you can do :

link_to "vote for this #{@retailer.title}" ...

For the image you can use image_tag :

http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-image_tag

Spyros
  • 46,820
  • 25
  • 86
  • 129
  • Hi, Thanks for your fast reply, your answer is part of the solution I guess. I want rails to render the code I pasted in my question " – Philip Apr 03 '11 at 19:13
  • Wrap everything around the link_to. Just add the html as you have it and inside the span add your link_to as i've shown :) – Spyros Apr 03 '11 at 19:15
  • Hi, I've changed it to this, but it doesn't register any votes when clicking on the button. – Philip Apr 03 '11 at 19:54
  • try without the remote and also check your posted action. – Spyros Apr 03 '11 at 20:39
  • Hi tried that and it didn't do anything, it's like the buttons taking over and doesnt apply the link? Thanks for all your help. – Philip Apr 04 '11 at 07:34
  • it should work. check the html to see if it's parsed correctly. – Spyros Apr 04 '11 at 07:36
  • Hi, This is what I got: – Philip Apr 04 '11 at 07:54
  • Well,, I made an alternative to the initial request... It's not perfect but it works, the irritating thing is that I have to make the background with the icon instead of separating them as I did before. But it works :) <% form_tag({:action => 'vote_up'}, :remote => true) do %> <%= submit_tag "Gilla #{@retailer.title}!", :class => 'like' %> <% end %> <% form_tag({:action => 'vote_down'}, :remote => true) do %> <%= submit_tag "", :class => 'disLike' %> <% end %> – Philip Apr 04 '11 at 09:41