lib/ocean/ocean_application_controller.rb
#
# This method finds the other resource for connect/disconnect, given the
# value of the param +href+, which should be a complete resource URI.
#
# Renders API errors if the +href+ arg is missing, can't be parsed, or
# the resource can't be found.
#
# Sets @connectee_class to the class of the resource pointed to by +href+,
# and @connectee to the resource itself.
#
This method finds the other resource for connect/disconnect, given the
value of the param +href+, which should be a complete resource URI.

Renders API errors if the +href+ arg is missing, can't be parsed, or
the resource can't be found.

Sets @connectee_class to the class of the resource pointed to by +href+,
and @connectee to the resource itself.
This method finds the other resource for connect / disconnect given the value of the param + href + which should be a complete resource URI . Renders API errors if the + href + arg is missing can ' t be parsed or the resource can ' t be found . Sets @connectee_class to the class of the resource pointed to by + href + and @connectee to the resource itself .
def find_connectee
    href = params[:href]
    render_api_error(422, "href query arg is missing") and return if href.blank?
    begin
      routing = Rails.application.routes.recognize_path(href)
    rescue ActionController::RoutingError
      render_api_error(422, "href query arg isn't parseable")
      return
    end
    @connectee_class = routing[:controller].classify.constantize
    @connectee = @connectee_class.find_by_id(routing[:id])
    render_api_error(404, "Resource to connect not found") and return unless @connectee
    true
  end
def find_connectee href = params [ :href ] render_api_error ( 422 , "href query arg is missing" ) and return if href . blank? begin routing = Rails . application . routes . recognize_path ( href ) rescue ActionController :: RoutingError render_api_error ( 422 , "href query arg isn't parseable" ) return end @connectee_class = routing [ :controller ] . classify . constantize @connectee = @connectee_class . find_by_id ( routing [ :id ] ) render_api_error ( 404 , "Resource to connect not found" ) and return unless @connectee true end
This method finds the other resource for connect/disconnect, given the
value of the param +href+, which should be a complete resource URI.
This method finds the other resource for connect / disconnect given the value of the param + href + which should be a complete resource URI .