2
나는 사용자의 commentable입니다 모델이 사용자가 댓글을 렌더링하는 부분이 있다는 것을 보여줍니다.레일 4 acts_as_commentable, 삭제 버튼/링크
<% @comments.each do |comment| %>
<p><%= time_ago_in_words(comment.created_at) %> ago</p>
<h4><%= comment.comment %></h4>
<% end %>
t에 링크 또는 버튼을 추가하는 데 문제가 있습니다. 그는 부분적으로 사용자가 (개별적으로 AJAX 호출을 통해) 삭제할 수 있습니다. 나는 이것이 기본 레일이라는 것을 알고 있지만 나는 여기서 완전히 잃어버린다.
추가 정보 :
class Comment < ActiveRecord::Base
include ActsAsCommentable::Comment
belongs_to :commentable, :polymorphic => true
default_scope -> { order('created_at ASC') }
belongs_to :user
end
나는이에 대한 간결하고 완전한 답변을 정말 감사하겠습니다.
현재 Comments는 routes.rb를 포함하지 않았습니다. 다른 사용자 작업에 대한 콜백에서만 설명이 작성되기 때문입니다.
routes.rb :
resources :comments, only: :destroy
UsersController :
def show
@comments = @user.comments.recent.page(params[:notifications]).per(10)
end
뷰/사용자의 해결책은 간단했다 평소와 같이