set_flash_message ArgumentError

81 views
Skip to first unread message

Tim Sjoberg

unread,
Oct 21, 2010, 6:19:54 AM10/21/10
to Devise
Hi

I've set up devise and it was working fine. However I needed to
automatically assign roles to users based on some information which is
already in the database.

#app/controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
include Devise::Controllers::InternalHelpers

def create
############
# some code which decides the roles. and puts them into a roles
hash
############

build_resource

if resource.save
roles.each do |role_name, associated_object|
role = Role.find_by_name!(role_name.to_s)
RolesUsers.create!(:role_id => role.id, :user_id =>
resource.id, :pb_user_id => associated_object.id, :pb_user_type =>
associated_object.class.to_s)
end

if resource.active?
set_flash_message :notice, :signed_up
sign_in_and_redirect(resource_name, resource)
else
set_flash_message :notice, :inactive_signed_up, :reason =>
resource.inactive_message.to_s
redirect_to after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords(resource)
render_with_scope :new
end
end

end

#routes.rb
devise_for :users, :controllers => {:registrations => "registrations"}

The code is not particularly important as it actually works. The user
is created and so are the roles. The problem is that when it gets to:
set_flash_message :notice, :inactive_signed_up, :reason =>
resource.inactive_message.to_s
I get an ArgumentError:
ArgumentError (wrong number of arguments (3 for 2)):
app/controllers/registrations_controller.rb:38:in
`set_flash_message'

Any idea why it is finding the wrong set_flash_message method (i
assume), and how to get it to find the correct one?

Tim

Tim Sjoberg

unread,
Oct 21, 2010, 10:49:30 AM10/21/10
to Devise
So it appear's that the latest gem version is quite different from the version on github. My bad
Reply all
Reply to author
Forward
0 new messages