No commit activity in last 3 years
No release in over 3 years
Patches ActionController::Parameters to let you easily permit parameters sometimes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 0.6.3
~> 10.0
~> 3.1

Runtime

>= 4.2.0
 Project Readme

RailsConditionalParams

This gem patches ActionController::Parameters to support conditional parameters—parameters that are permitted only if some condition is true. Basically, it ensures that any hash key passed to permit() with true as its value is made into a permitted key, while keys passed with false or nil are ignored.

It is compatible with Rails 4.2 and later, including Rails 5.

Installation

Add this line to your application's Gemfile:

gem 'rails_conditional_params'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails_conditional_params

Usage

params.permit(:title, :body, published: admin?)
	# published will only be permitted if admin? returns true

Contributing

  1. Fork it ( https://github.com/brentdax/rails_conditional_params/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request