Find correct user on users#show
This commit is contained in:
parent
d723c46c2a
commit
71fc48cd71
2 changed files with 4 additions and 2 deletions
|
@ -42,6 +42,6 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def init
|
||||
@user = User.find_by_id(params[:id]) || current_user
|
||||
@user ||= current_user
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,7 +25,9 @@ class Ability
|
|||
def initialize_user(user)
|
||||
can :read, :all
|
||||
can :manage, User, id: user.id
|
||||
can :create, Order, user: user
|
||||
can :create, Order do |order|
|
||||
order.user == user
|
||||
end
|
||||
can :destroy, Order do |order|
|
||||
order.try(:user) == user && order.deletable
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue