I am getting an unexpected behaviour for a simple cancancan authorization.
ability.rb
class Ability
  include CanCan::Ability
  def initialize(user)
    # Define abilities for the passed in user here. For example:
    #
    user ||= User.new # guest user (not logged in)
    if user.is_admin?
        can :manage, :all
    elsif user.is_standard?
        can :manage, ServiceOrder, {user_id: user.id}
        can :manage, ServiceOrderDetail, :service_order => { :user_id => user.id }
    end
service_order.rb controller (partially shown)
class ServiceOrdersController < ApplicationController
  authorize_resource
  def show
    @service_order = ServiceOrder.includes(:service_order_details).find(params[:id])
  end
end
This does not work, as it lets the controller show ANY service_order record, instead of just those owned by the current_user.
The only way that this works is if I manually authorize the controller adding:
authorize! :show, @service_order
like this:
  def show
    @service_order = ServiceOrder.includes(:service_order_details).find(params[:id])
    authorize! :show, @service_order
  end
which makes no sense since authorize_resource is supposed to be doing that.