Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ujifgc committed May 8, 2014
1 parent 18095fd commit 7fb7160
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion padrino-core/lib/padrino-core/application/params_protection.rb
Expand Up @@ -29,7 +29,14 @@ module ClassMethods
# post :update, :params => true
# @example
# params :name, :email, :password => prox{ |v| v.reverse }
# post :update
# 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
#
def params(*allowed_params)
allowed_params = prepare_allowed_params(allowed_params)
Expand Down Expand Up @@ -76,6 +83,12 @@ module InstanceMethods
# filter_params!( { "id" => "", "child" => { "name" => "manny" } },
# { "id" => Integer, "child" => { "name" => proc{ |v| v.camelize } } } )
# # => { "id" => nil, "child" => { "name" => "Manny" } }
# filter_params!( { "a" => ["1", "2", "3"] },
# { "a" => true } )
# # => { "a" => ["1", "2", "3"] }
# filter_params!( { "persons" => {"p-1" => { "name" => "manny", "age" => "50" }, "p-2" => { "name" => "richard", "age" => "50" } } },
# { "persons" => { "name" => true } } )
# # => { "persons" => {"p-1" => { "name" => "manny" }, "p-2" => { "name" => "richard" } } }
#
def filter_params!(params, allowed_params)
params.each do |key,value|
Expand Down

0 comments on commit 7fb7160

Please sign in to comment.