Class: RestArea::MessageController

Inherits:
ApplicationController show all
Includes:
GetsKlass
Defined in:
app/controllers/rest_area/message_controller.rb

Instance Method Summary collapse

Methods included from GetsKlass

#get_klass, #test_class

Instance Method Details

#getObject



6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/rest_area/message_controller.rb', line 6

def get
  if @message_serializer
    render json: @resource.find(params[:id]).send(@message).all, each_serializer: @message_serializer, root:@message
  elsif @message_class
    render json: { @message => @resource.find(params[:id]).send(@message).all }.to_json(root:false)
  elsif @resource.can_send?(@message)
    render json: @resource.find(params[:id]).send(@message).to_json(root:false)
  else
    raise ActionController::RoutingError.new("Resource Does Not Exist")
  end
end