moved privileged? method from answer_controller to application_controller
This commit is contained in:
parent
3994bdeb02
commit
6fb97c9ecc
|
@ -8,6 +8,8 @@ class Ajax::AnswerController < ApplicationController
|
||||||
|
|
||||||
answer = Answer.find(params[:answer])
|
answer = Answer.find(params[:answer])
|
||||||
|
|
||||||
|
puts ">>>>>>>>>>>>", privileged?.inspect
|
||||||
|
|
||||||
unless answer.user == current_user || privileged?
|
unless answer.user == current_user || privileged?
|
||||||
@status = :nopriv
|
@status = :nopriv
|
||||||
@message = "check yuor privlegs"
|
@message = "check yuor privlegs"
|
||||||
|
@ -23,15 +25,4 @@ class Ajax::AnswerController < ApplicationController
|
||||||
@message = "Successfully deleted answer."
|
@message = "Successfully deleted answer."
|
||||||
@success = true
|
@success = true
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
# TODO:
|
|
||||||
def privileged?
|
|
||||||
if current_user && current_user.admin?
|
|
||||||
true
|
|
||||||
else
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,14 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
before_filter :configure_permitted_parameters, if: :devise_controller?
|
before_filter :configure_permitted_parameters, if: :devise_controller?
|
||||||
|
|
||||||
|
def privileged?
|
||||||
|
if current_user && current_user.admin?
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def configure_permitted_parameters
|
def configure_permitted_parameters
|
||||||
|
|
Loading…
Reference in New Issue