2011-04-03 43 views
0

嗨 我已經安裝了Thumbs_up gem,效果很好。Rails 3 - Thumbs_up - 自定義按鈕

但現在我想做一個按鈕,這樣做是一樣的。

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

我的問題是,我想有一個圖像和按鈕內的文本與文本「像<%= @ retailer.title%>」,(像按​​鈕一樣youtubes)。

按鈕我的編碼方式類似於this.`

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

我怎樣才能做到在Rails3中這些功能的按鈕?

由於提前,

回答

0

我不知道我是否正確地理解了,而是增加你的文本中的變量,你可以這樣做:

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

對於您可以使用IMAGE_TAG圖像:

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

+0

嗨, 感謝您的回覆速度快,你的回答是我猜的解決方案的一部分。 我想要rails來渲染粘貼在我的問題中的代碼「

+0

將所有東西都包裹在link_to中。添加HTML,因爲你有它,並在跨度添加您的link_to,因爲我已經顯示:) – Spyros 2011-04-03 19:15:31

+0

嗨, 我已經改變它到這個,但它沒有登記任何投票時點擊按鈕 <按鈕角色=「按鈕」class =「like」> <%= link_to(「vote for #{@retailer.title}!」,vote_up_retailer_path(@retailer),:remote => true,:method =>:帖子)%> Philip 2011-04-03 19:54:38