fixed delete button not showing up

This commit is contained in:
nilsding 2014-11-28 19:23:54 +01:00
parent eed67aeaa2
commit dc83151e65
4 changed files with 6 additions and 14 deletions

View File

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

View File

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

View File

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

View File

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