2
我想加上我的文章的按鈕,這樣我可以知道的數據庫上的點擊,更新計數器,我使用mongoid的次數,我的模型是:添加按鈕,點擊計數器3
class Article
include Mongoid::Document
include Mongoid::Timestamps
field :title, :type => String
field :content, :type => String
field :likes, :type => Integer ,:default => 0
field :dislikes, :type =>Integer, :default => 0
field :spam, :type => Integer, :default => 0
end
我的文章顯示控制器:
def show
@article = Article.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @article }
end
end
我對錶演的看法是:
<p id="notice"><%= notice %></p>
<p>
<b>Title:</b>
<%= @article.title %>
</p>
<p>
<b>Content:</b>
<%= raw @article.content %>
</p>
Likes : <%= @article.likes %> <br/>
Dislikes : <%= @article.dislikes %><br/>
Spams : <%= @article.spam %><br/>
<%= link_to 'Edit', edit_article_path(@article) %> |
<%= link_to 'Back', articles_path %>
我覺得任何事情它在互聯網上。
我該如何實現它?