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])
unless answer.user == current_user || privileged?
unless privileged? answer.user
@status = :nopriv
@message = "check yuor privlegs"
@success = false

View File

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

View File

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

View File

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