Ruby on rails 如何使用Opinio gem删除/销毁评论
我正在使用来处理对我的一个模型的评论。我还使用cancan进行身份验证 我可以添加评论,没有问题,但我不知道如何删除评论。我只是得到一个文本字符串,上面写着“unauthorized”。就这样 以下是我的渲染代码:Ruby on rails 如何使用Opinio gem删除/销毁评论,ruby-on-rails,cancan,Ruby On Rails,Cancan,我正在使用来处理对我的一个模型的评论。我还使用cancan进行身份验证 我可以添加评论,没有问题,但我不知道如何删除评论。我只是得到一个文本字符串,上面写着“unauthorized”。就这样 以下是我的渲染代码: <!-- _comment.html.erb (generated by Opinio) --> <% reply = defined?(reply) ? reply : false %> <dt id="comment_<%= comment.i
<!-- _comment.html.erb (generated by Opinio) -->
<% reply = defined?(reply) ? reply : false %>
<dt id="comment_<%= comment.id %>"><%= link_to comment.owner.name, comment.owner %></dt>
<dd class="well">
<%= simple_format(comment.body) %>
<% if can? :delete, comment%>
<%= link_to t('opinio.actions.delete'), comment_path(comment), :method => :delete%>
<% end %>
<% if Opinio.accept_replies && !reply %>
<span><%= link_to t('opinio.actions.reply'), reply_comment_path(comment), :remote => true %></span>
<ul id="comment_<%= comment.id %>_replies" class="replies">
<%= render :partial => "opinio/comments/comment", :collection => comment.comments, :locals => {:reply => true} %>
</ul>
<% end %>
</dd>
我已经查阅了意见,发现我认为不合格的测试:
#In opinio gem: comments_controller.rb
if can_destroy_opinio?(@comment)
任何帮助都会很好。您能将opinio的
注释子类化为控制器的并覆盖可以销毁\u opinio
?如果没有,您能否重新打开opinio的注释\u controller
并重新定义是否可以销毁\u opinio
(通常称为猴子补丁)
#In opinio gem: comments_controller.rb
if can_destroy_opinio?(@comment)