plataformatec/devise — pull request #2354 by latortuga (2013-03-28 16:42:35+00:00)
Title: Rails 4 strong parameters support

This branch is a result of a discussion with @lucasmazza and @carlosantoniodasilva a few weeks ago about the best way to allow flexible support for strong_parameters. I based my branch of the rails4 branch however I also rebased the final result to master. The result is a slight deviation from the original plan but I think it represents a decent compromise between setting up a default configuration that is easy to override via before_filter.

This sets up a new class `Devise::ParameterSanitizer` to handle permitting parameters for Devise in a central and configurable way. I added tests for the intended usage of it.

Use case: need to add a pin field for logging in? Simply override the session params:

```ruby
class ApplicationController
prepend_before_filter :add_allowed_devise_session_params

private

def add_allowed_devise_session_params
parameters_sanitizer.permit_devise_param(:sessions, :pin)
end
end
```

Everything is green except for one test that I wasn't sure how to handle. It's a scoped views test that simply does `post :create` with no params and expects a 200 OK and is instead getting a parameter missing (due to no :user being passed in the params).