https://github.com/bumi/params_required
Rails plugin to validate if certain params are present.
https://github.com/bumi/params_required
Last synced: 4 months ago
JSON representation
Rails plugin to validate if certain params are present.
- Host: GitHub
- URL: https://github.com/bumi/params_required
- Owner: bumi
- License: mit
- Created: 2009-02-20T12:53:46.000Z (over 17 years ago)
- Default Branch: master
- Last Pushed: 2009-02-20T12:54:06.000Z (over 17 years ago)
- Last Synced: 2025-01-01T18:31:30.258Z (over 1 year ago)
- Homepage: http://railslove.com
- Size: 78.1 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: MIT-LICENSE
Awesome Lists containing this project
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