dup

dup() Instance Public methods Returns an exact copy of the ActionController::Parameters instance. permitted state is kept on the duped object. params = ActionController::Parameters.new(a: 1) params.permit! params.permitted? # => true copy_params = params.dup # => {"a"=>1} copy_params.permitted? # => true

converted_arrays

converted_arrays() Instance Public methods Attribute that keeps track of converted arrays, if any, to avoid double looping in the common use case permit + mass-assignment. Defined in a method to instantiate it only if needed.

[]

[](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

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

model_name_from_record_or_class

model_name_from_record_or_class(record_or_class) Instance Public methods

convert_to_model

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

new

new(format) Class Public methods

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

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

response

response() Instance Public methods