randombits
randombits

Reputation: 48450

Devise throwing exception when attempting to add parameter to sanitizer

I am following the instructions here in order to add two parameters to my sign up / registration form in a Ruby on Rails + devise based application: http://devise.plataformatec.com.br/#getting-started/strong-parameters

My controller is straight forward:

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception

  before_filter :configure_permitted_parameters, if: :devise_controller?

  before_filter :authenticate_user!

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) << :username
  end
end

The error I'm getting is the following:

NoMethodError in Devise::SessionsController#new 

undefined method `<<' for {}:ActionController::Parameters

Am I using the wrong version of Devise or something? I have gem 'devise', :git => 'https://github.com/plataformatec/devise', :branch => 'v3.0' specified in my Gemfile, nothing else is out of the ordinary.

Upvotes: 1

Views: 312

Answers (1)

Peter Brown
Peter Brown

Reputation: 51697

This feature requires Devise 3.1.0.rc according to an issue opened on the Devise repo.

Upvotes: 2

Related Questions