moved privileged? method from answer_controller to application_controller

This commit is contained in:
nilsding 2014-11-27 11:51:05 +01:00
parent 3994bdeb02
commit 6fb97c9ecc
2 changed files with 11 additions and 12 deletions

View File

@ -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

View File

@ -4,7 +4,15 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
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