bumi / params_required

Rails plugin to validate if certain params are present.

This URL has Read+Write access

bumi (author)
Fri Feb 20 04:52:35 -0800 2009
commit  26ab339db67cb483e564f8b233ac1c6e1188b72a
tree    76058501bf8d12be9723278b132ba3d16198e3a9
parent  d184fa63877ba7cebb773814631d95e799cff29a
name age message
file MIT-LICENSE Loading commit data...
file README
file Rakefile
file init.rb
file install.rb
directory lib/
directory tasks/
directory test/
file uninstall.rb
README
ParamsRequired
=============

params_required adds a before_filter which tests if certain params are set. Otherwise HTTP status 404 will be rendered. 


Example
=======

params_required( [array] required params, [hash] before_filter options)

class PostsController < ApplicationController

  # tests if params[:blog_id] and params[:user_id] are present
  params_required :blog_id, :user_id, :except => [:show]
  
  # tests if params[:user][:blog_id] is present
  params_required :user => :blog_id
  
end


Note
======

this is experimental and perhaps there are better ways to do something like this? 


Copyright (c) 2008 [Michael Bumann], released under the MIT license