Module: Padrino::ParamsProtection::ClassMethods

### Home Classes Methods

### In Files

- lib/padrino-core/application/params_protection.rb

### Methods

- #params

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Padrino
- Padrino::Application
- Padrino::ApplicationLoadError
- Padrino::ApplicationSetup
- Padrino::ApplicationSetup::ClassMethods
- Padrino::AuthenticityToken
- Padrino::Cli
- Padrino::Cli::Adapter
- Padrino::Cli::Base
- Padrino::Cli::Launcher
- Padrino::Filter
- Padrino::Flash
- Padrino::Flash::Helpers
- Padrino::Flash::Storage
- Padrino::Loader
- Padrino::Logger
- Padrino::Logger::Colorize
- Padrino::Logger::Extensions
- Padrino::Logger::Rack
- Padrino::Module
- Padrino::Mounter
- Padrino::Mounter::ApplicationWrapper
- Padrino::Mounter::MounterException
- Padrino::ParamsProtection
- Padrino::ParamsProtection::ClassMethods
- Padrino::ParamsProtection::InstanceMethods
- Padrino::Reloader
- Padrino::Reloader::Rack
- Padrino::Reloader::Storage
- Padrino::Router
- Padrino::Routing
- Padrino::Routing::ClassMethods
- Padrino::Routing::InstanceMethods
- Padrino::Routing::Parent
- Padrino::Routing::UnrecognizedException
- Padrino::Server
- Padrino::ShowExceptions
- Padrino::Tasks
- HttpRouter
- HttpRouter::Node
- HttpRouter::Node::FreeRegex
- HttpRouter::Node::Glob
- HttpRouter::Node::Path
- HttpRouter::Node::SpanningRegex
- HttpRouter::Request
- HttpRouter::Route
- Sinatra
- Sinatra::Base
- Sinatra::Request
- Kernel
- Object
- PadrinoTasks

No matching classes.

# Padrino::ParamsProtection::ClassMethods

### Public Instance Methods

params(*allowed_params) click to toggle source

Implements filtering of url query params. Can prevent mass-assignment.

@example

    post :update, :params => [:name, :email]
    post :update, :params => [:name, :id => Integer]
    post :update, :params => [:name => proc{ |v| v.reverse }]
    post :update, :params => [:name, :parent => [:name, :position]]
    post :update, :params => false
    post :update, :params => true

@example

    params :name, :email, :password => prox{ |v| v.reverse }
    post :update

@example

    App.controller :accounts, :params => [:name, :position] do
      post :create
      post :update, :with => [ :id ], :params => [:name, :position, :addition]
      get :show, :with => :id, :params => false
      get :search, :params => true
    end

    # File lib/padrino-core/application/params_protection.rb, line 45
    def params(*allowed_params)
      allowed_params = prepare_allowed_params(allowed_params)
      condition do
        @original_params = params.deep_dup
        filter_params!(params, allowed_params)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.