GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of wycats/merb-plugins
Description: Merb Plugins: Even more modules to hook up your Merb installation
Homepage: http://www.merbivore.com
Clone URL: git://github.com/auser/merb-plugins.git
merb-plugins / merb_param_protection
name age message
..
file LICENSE Wed Jan 09 11:25:39 -0800 2008 Merb Param Protection plugin added to core plugins [lancecarlson@gmail.com]
file README Thu Jan 10 17:29:25 -0800 2008 Fixed spacial issues with README [lancecarlson@gmail.com]
file Rakefile Fri Feb 29 20:20:48 -0800 2008 prep for 0.9.1 release [ivey]
file TODO Thu Jan 10 17:32:40 -0800 2008 Updated TODO [lancecarlson@gmail.com]
directory lib/ Thu Jan 10 09:43:35 -0800 2008 Implemented params_protected [lancecarlson@gmail.com]
directory log/ Wed Jan 09 11:25:39 -0800 2008 Merb Param Protection plugin added to core plugins [lancecarlson@gmail.com]
directory script/ Wed Jan 09 11:25:39 -0800 2008 Merb Param Protection plugin added to core plugins [lancecarlson@gmail.com]
directory spec/ Wed Jan 09 22:33:53 -0800 2008 Params accessible now works [lancecarlson@gmail.com]
README
merb_param_protection
=================

This plugin exposes two new controller methods which allow us to simply and flexibly filter the parameters available 
within the controller.

Setup:
The request sets: 

  params => { :post => { :title => "ello", :body => "Want it", :status => "green", :author_id => 3, :rank => 4 } }

  Example 1: params_accessable
  MyController < Application
    params_accessible :post => [:title, :body]
  end

  params.inspect # => { :post => { :title => "ello", :body => "Want it" } }

So we see that params_accessible removes everything except what is explictly specified.

  Example 2: params_protected
  MyOtherController < Application
    params_protected :post => [:status, :author_id]
  end

  params.inspect # => { :post => { :title => "ello", :body => "Want it", :rank => 4 } }

We also see that params_protected removes ONLY those parameters explicitly specified.