custom

custom(mime_type, &block) Instance Public methods

negotiate_format

negotiate_format(request) Instance Public methods

response

response() Instance Public methods

respond_to

respond_to(*mimes, &block) Instance Public methods Without web-service support, an action which collects the data for displaying a list of people might look something like this: def index @people = Person.all end Here's the same action, with web-service support baked in: def index @people = Person.all respond_to do |format| format.html format.xml { render xml: @people } end end What that says is, âif the client wants HTML in response to this action, just resp

respond_with

respond_with(*resources, &block) Instance Public methods For a given controller action, #respond_with generates an appropriate response based on the mime-type requested by the client. If the method is called with just a resource, as in this example - class PeopleController < ApplicationController respond_to :html, :xml, :json def index @people = Person.all respond_with @people end end then the mime-type of the response is typically selected based on the reque

new

new(format) Class Public methods

convert_to_model

convert_to_model(object) Instance Public methods Converts the given object to an ActiveModel compliant one.

model_name_from_record_or_class

model_name_from_record_or_class(record_or_class) Instance Public methods

new

new(attributes = nil) Class Public methods Returns a new instance of ActionController::Parameters. Also, sets the permitted attribute to the default value of ActionController::Parameters.permit_all_parameters. class Person < ActiveRecord::Base end params = ActionController::Parameters.new(name: 'Francesco') params.permitted? # => false Person.new(params) # => ActiveModel::ForbiddenAttributesError ActionController::Parameters.permit_all_parameters = true params = Action

[]

[](key) Instance Public methods Returns a parameter for the given key. If not found, returns nil. params = ActionController::Parameters.new(person: { name: 'Francesco' }) params[:person] # => {"name"=>"Francesco"} params[:none] # => nil