def load_resource(options = {})

      # Determine the name based on the current controller if not specified.
      resource_name = options[:name] || controller_name.singularize

      # Determine the class based on the resource name if not provided.
      # FIXME: Do not hard code engine name 
      resource_class = options[:class] || "Hicube::#{resource_name.singularize.camelize}".classify.constantize

      resource = if resource_class == Hicube::Account
        # resource = Hicube::Account.first
        current_account
      else
        # resource = resource_class.unscoped.find(params[:id])
        resource_class.unscoped.where(account: current_account).find(params[:id])
      end
      # # Confirm current user has permission to view resource.
      # unless resource.account == current_account
      #   # TODO: log an audit event.

      #   # SECURITY RISK: The user should not be able to distinguish between a
      #   # non-existant resource and another user's resource. This way you can't
      #   # probe to the system and determine another account's data.
      #   raise Mongoid::Errors::DocumentNotFound.new(resource_class, :id => params[:id])
      # end

      # Set an instance variable @resource_name to the resource.
      instance_variable_set("@#{resource_name}", resource)

      rescue Mongoid::Errors::DocumentNotFound => e
      notify :error, ::I18n.t('messages.resource.not_found',
        :type     => resource_class.model_name.human,
        :criteria => resource_class.human_attribute_name(:id),
        :value    => params[:id]
      )
      redirect_to :action => :index
    end
def load_resource(options = {})

      # Determine the name based on the current controller if not specified.
      resource_name = options[:name] || controller_name.singularize

      # Determine the class based on the resource name if not provided.
      # FIXME: Do not hard code engine name 
      resource_class = options[:class] || "Hicube::#{resource_name.singularize.camelize}".classify.constantize

      resource = if resource_class == Hicube::Account
        # resource = Hicube::Account.first
        current_account
      else
        # resource = resource_class.unscoped.find(params[:id])
        resource_class.unscoped.where(account: current_account).find(params[:id])
      end
      # # Confirm current user has permission to view resource.
      # unless resource.account == current_account
      #   # TODO: log an audit event.

      #   # SECURITY RISK: The user should not be able to distinguish between a
      #   # non-existant resource and another user's resource. This way you can't
      #   # probe to the system and determine another account's data.
      #   raise Mongoid::Errors::DocumentNotFound.new(resource_class, :id => params[:id])
      # end

      # Set an instance variable @resource_name to the resource.
      instance_variable_set("@#{resource_name}", resource)

      rescue Mongoid::Errors::DocumentNotFound => e
      notify :error, ::I18n.t('messages.resource.not_found',
        :type     => resource_class.model_name.human,
        :criteria => resource_class.human_attribute_name(:id),
        :value    => params[:id]
      )
      redirect_to :action => :index
    end
Load the relevant resource based on the current controller name.