Skip to content

Instantly share code, notes, and snippets.

@chocnut
Created March 13, 2014 13:20
Show Gist options
  • Save chocnut/9528309 to your computer and use it in GitHub Desktop.
Save chocnut/9528309 to your computer and use it in GitHub Desktop.
class Api::V1::AdvisorUserEntriesController < Api::V1::BaseController
respond_to :json
def show
result = {
:user => @advisor_user_entry,
:advisor_user_entry => @advisor_user_entry ,
:meta => { :message => "Returned an existing User." }
}
success_respond(result)
end
end
class Api::V1::BaseController < ApplicationController
def success_respond(data, status_code=:ok)
render json: data, status: status_code
end
def error_respond(message, status_code)
render json: { :message => message }, :status => status_code
end
end
class Api::V1::MembersController < Api::V1::AdvisorUserEntriesController
def show
hash_replacement = JSON(super[0])
hash_replacement["members"] = hash_replacement["advisor_user_entry"]
hash_replacement.delete "advisor_user_entry"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment