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