Ruby on rails 作为不更新的VOU votable按钮
问题如上所述,无法使“喜欢”按钮工作,发布的更改如下。先谢谢你。我修改了路线、模型视图和控制器,如下所示 充当可Votable迁移Ruby on rails 作为不更新的VOU votable按钮,ruby-on-rails,ruby,Ruby On Rails,Ruby,问题如上所述,无法使“喜欢”按钮工作,发布的更改如下。先谢谢你。我修改了路线、模型视图和控制器,如下所示 充当可Votable迁移 class ActsAsVotableMigration < ActiveRecord::Migration def self.up create_table :votes do |t| t.references :votable, :polymorphic => true t.references :voter, :polymorphic =
class ActsAsVotableMigration < ActiveRecord::Migration
def self.up
create_table :votes do |t|
t.references :votable, :polymorphic => true
t.references :voter, :polymorphic => true
t.boolean :vote_flag
t.string :vote_scope
t.timestamps
end
add_index :votes, [:votable_id, :votable_type]
add_index :votes, [:voter_id, :voter_type]
add_index :votes, [:voter_id, :voter_type, :vote_scope]
add_index :votes, [:votable_id, :votable_type, :vote_scope]
end
def self.down
drop_table :votes
end
end
模型
(User)has_many :posts
(Post)has_many :comments
(Post)belongs_to :user
(Comment)belongs_to :post
财务主任(职位)
索引(员额)
:post,:class=>“do%>
如果你想打造一个漂亮的投票系统,你可以使用这些宝石
我正在我的应用程序上使用拇指,它工作得很好错误消息是什么?谢谢,我会尝试一下,会让你知道它是如何工作的
(User)has_many :posts
(Post)has_many :comments
(Post)belongs_to :user
(Comment)belongs_to :post
def like
@post= Post.find(params[:id])
@post.liked_by current_user
redirect_to :back
flash[:notice]="Liked!"
end
<%= link_to like_user_post_path(post.user,post), :method => :post ,:class =>"" do%>
<span class="btn btn-primary editlike">
<%=post.likes.size %>
<i class="icon-heart ">
</i></span><%end %>