Find correct user on users#show

This commit is contained in:
benji 2016-02-04 21:03:03 +01:00
parent d723c46c2a
commit 71fc48cd71
2 changed files with 4 additions and 2 deletions

View file

@ -42,6 +42,6 @@ class UsersController < ApplicationController
end
def init
@user = User.find_by_id(params[:id]) || current_user
@user ||= current_user
end
end

View file

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