platanus / potassium

A Rails application generator by Platanus, inspired by Suspenders
MIT License
232 stars 17 forks source link

Improved API responder and updated active_model_serializers #165

Closed iobaixas closed 5 years ago

iobaixas commented 6 years ago

Api responder should look like:

class ApiResponder < ActionController::Responder
  def api_behavior
    raise MissingRenderer.new(format) unless has_renderer?

    if delete?
      head :no_content
    elsif post?
      display resource, status: :created
    else
      display resource
    end
  end
end

Responder should be located in app/responders/api_responder.rb

We should also move to:

gem 'active_model_serializers', '~> 0.10.7'

And add the following initializer code:

ActiveModelSerializers.config.adapter = :json

blackjid commented 5 years ago

@iobaixas podrias revisar este issue para ver si lo mantenemos...