현재 사용자가 작성하지 않은 게시물의 버튼을 숨겼습니다. 에서 게시물을 업데이트, 편집 또는 삭제할 수 없도록하려면 posts_controller
어떻게 해야 합니까? if @post.user == current_user
편집, 업데이트 및 삭제 방법을 사용해 보았지만 스택 추적을 반환합니다.
Missing template posts/update, application/update with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "/Users/user1/workspace/webapp/app/views" * "/Users/user1/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/devise-3.5.2/app/views"
게시물을 편집하려는 사용자가 소유자가 아닌 경우 편집, 업데이트 또는 삭제를 차단하려면 어떻게해야합니까?
무단 액세스를위한 템플릿이 있어야합니다. 그렇지 않으면 URL로 리디렉션 할 수 있습니다 if @post.user == current_user
. 아래와 같이
if @post.user == current_user
flash.now[:error] = 'unauthorized access!'
redirect_to posts_path
end
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다