fixed delete button not showing up
This commit is contained in:
parent
eed67aeaa2
commit
dc83151e65
|
@ -8,7 +8,7 @@ class Ajax::AnswerController < ApplicationController
|
|||
|
||||
answer = Answer.find(params[:answer])
|
||||
|
||||
unless answer.user == current_user || privileged?
|
||||
unless privileged? answer.user
|
||||
@status = :nopriv
|
||||
@message = "check yuor privlegs"
|
||||
@success = false
|
||||
|
|
|
@ -5,12 +5,8 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
before_filter :configure_permitted_parameters, if: :devise_controller?
|
||||
|
||||
def privileged?
|
||||
if current_user && current_user.admin?
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
def privileged?(user)
|
||||
(current_user == user && current_user.admin?) ? true : false
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -46,11 +46,7 @@ module ApplicationHelper
|
|||
count.count
|
||||
end
|
||||
|
||||
def privileged?
|
||||
if current_user && current_user.admin?
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
def privileged?(user)
|
||||
(current_user == user && current_user.admin?) ? true : false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
%hr/
|
||||
%p= a.content
|
||||
%br/
|
||||
- if privileged?
|
||||
- if privileged? a.user
|
||||
%button.btn.btn-danger{name: 'ab-destroy', 'data-a-id' => a.id}
|
||||
Delete
|
Loading…
Reference in New Issue