Skip to content

Instantly share code, notes, and snippets.

@deathbob
Created February 2, 2011 02:37
Show Gist options
  • Select an option

  • Save deathbob/807148 to your computer and use it in GitHub Desktop.

Select an option

Save deathbob/807148 to your computer and use it in GitHub Desktop.
Hack for devise after_set_user on warden::manager
# config/initializers/anything.rb
Warden::Manager.after_set_user do |user, auth, opts|
puts "Hello"
debugger
puts "Hi"
end
# fire up server
# rails server --debugger
# when you hit debugger
(rdb:2) pp Warden::Manager.instance_variable_get("@_after_set_user")
[[#<Proc:0x00000001033d44c0@/Library/Ruby/Gems/1.8/gems/devise-1.1.5/lib/devise/hooks/activatable.rb:5>,
{}],
[#<Proc:0x0000000102d9bf68@/Library/Ruby/Gems/1.8/gems/devise-1.1.5/lib/devise/rails/warden_compat.rb:112>,
{:event=>[:set_user, :authentication]}],
[#<Proc:0x000000010591e938@/Users/bob/src/lva/config/initializers/rails_hacks.rb:66>,
{}],
[#<Proc:0x0000000104f57ad0@/Library/Ruby/Gems/1.8/gems/devise-1.1.5/lib/devise/hooks/trackable.rb:5>,
{:event=>[:set_user, :authentication]}]]
(rdb:2) Warden::Manager.instance_variable_get("@_after_set_user").size
4
(rdb:2) Warden::Manager.instance_variable_get("@_after_set_user").delete_if{|x| x.first.to_s.match(/trackable/)}
[[#<Proc:0x00000001033d44c0@/Library/Ruby/Gems/1.8/gems/devise-1.1.5/lib/devise/hooks/activatable.rb:5>, {}], [#<Proc:0x0000000102d9bf68@/Library/Ruby/Gems/1.8/gems/devise-1.1.5/lib/devise/rails/warden_compat.rb:112>, {:event=>[:set_user, :authentication]}], [#<Proc:0x000000010591e938@/Users/bob/src/lva/config/initializers/rails_hacks.rb:66>, {}]]
(rdb:2) Warden::Manager.instance_variable_get("@_after_set_user").size
3
(rdb:2) pp Warden::Manager.instance_variable_get("@_after_set_user")
[[#<Proc:0x00000001033d44c0@/Library/Ruby/Gems/1.8/gems/devise-1.1.5/lib/devise/hooks/activatable.rb:5>,
{}],
[#<Proc:0x0000000102d9bf68@/Library/Ruby/Gems/1.8/gems/devise-1.1.5/lib/devise/rails/warden_compat.rb:112>,
{:event=>[:set_user, :authentication]}],
[#<Proc:0x000000010591e938@/Users/bob/src/lva/config/initializers/rails_hacks.rb:66>,
{}]]
(rdb:2)
Of course all this could be done in your initializer, this is just to get in there and see what knobs and levers are available to fiddle with.
@bradfordcp

Copy link
Copy Markdown

Do you have an example of popping that proc out of the array?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment