acts_as_voteable和vote_fu在軌道上不工作3.是否有工作?是否有可用於rails 3的投票插件?
2
A
回答
3
它們設置起來非常簡單。這裏有一個你可以開始:
class Object < ActiveRecord::Base
has_many :votes, :as => :votable
has_many :voting_users,
:through => :votes,
:source => :user
#object_controller
def vote_up
get_vote
@vote.value += 1 unless @vote.value == 1
@vote.save
respond_to do |format|
format.html {render :action => 'view'}
format.js { render :action => 'vote'}
end
end
private
def get_vote
current_object = Objects.detect{|r| r.id == params[:id].to_i}
@object = current_object
@vote = current_object.votes.find_by_user_id(current_user.id)
unless @vote
@vote = Vote.create(:user_id => current_user.id, :value => 0)
current_object.votes << @vote
end
end
1
Make_votable看起來像一個真棒和易於實施的寶石。
2
還有vote_fu和v ote_fu_rails3。
1
我使用的是Thumbs Up,它的功能就像一個魅力。這是一個改良的vote_fu Rails 3.
相關問題
- 1. 檢查用戶是否投票投票
- 2. Rails 3 - vote_fu - link_to投票?
- 3. 投票按鈕,是和否Rails 4
- 4. Rails 3 - vote_fu - 用戶投票集合
- 5. Rails 3 - vote_fu - 查詢具體投票選民投票
- 6. 是否有像Elgg這樣的插件可用於Ruby on Rails?
- 7. Rails沒有登錄投票?
- 8. Rails的JavaScript投票
- 9. 檢查用戶是否投票,如果不保存投票
- 10. 如何檢查用戶是否已投票進行投票?
- 11. 在rails 3中投票應用程序:我如何鏈接到投票方法?
- 12. 檢查是否有人投票
- 13. 基於投票投票的JQuery多個百分比投票
- 14. 事件是否建立在投票上?
- 15. Rails投票Ajax(acts_as_votable)
- 16. Rails投票站點
- 17. 的Rails充當可投票檢查,如果用戶登錄到投票
- 18. 投票投票牆
- 19. 如何檢查用戶是否投票支持名人Rails 4?
- 20. WordPress的「投票」插件幫助
- 21. 檢測用戶是否先前投票?
- 22. Django:確定用戶是否投了票
- 23. 插件添加投票如digg
- 24. Rails的CSS3投票欄
- 25. Rails 3:阻止用戶對自己的內容進行投票
- 26. Rails:作爲可投票的寶石 - 允許無限票數
- 27. 投票欄顯示沒有投票
- 28. 是否有用於.NET的OpenSocial插件
- 29. 投票與長投票
- 30. 投票 - 票數與投票率?
太棒了,感謝您的代碼。我們可能會把它放在這個方向。 – marketer 2010-11-17 01:29:58
我是在同一個地方,找不到寶石,所以只寫了這個。 – Trip 2010-11-17 19:14:51