HaaR
HaaR

Reputation: 1453

authenticate_user! hijacking the registrations/create method

The problem I'm having seems to be that Devise's authenticate_#{role}! method is hijacking my registration attempt.

Started GET "/client/sign_up" for 127.0.0.1 at 2012-01-14 12:02:52 +0000
  Processing by Client::RegistrationsController#new as HTML
Rendered /Users/robertwwhite/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.5.3/app/views/devise/shared/_links.erb (1.4ms)
Rendered client/registrations/new.html.haml within layouts/application (97.6ms)
Rendered client/_navigation.html.haml (1.6ms)
Rendered shared/_flash_messages.html.haml (0.1ms)
Completed 200 OK in 126ms (Views: 116.4ms | ActiveRecord: 7.2ms)

Started POST "/client" for 127.0.0.1 at 2012-01-14 12:02:58 +0000
  Processing by WishesController#index as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"vq3wgsQeb4eoxhb3sw2Q2kd4edIoOxIfrzJ/WzJUAn0=", "client"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
Completed 401 Unauthorized in 13ms

Started GET "/client/sign_in" for 127.0.0.1 at 2012-01-14 12:02:58 +0000
  Processing by Client::SessionsController#new as HTML
Rendered /Users/robertwwhite/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.5.3/app/views/devise/shared/_links.erb (1.0ms)
Rendered client/sessions/new.html.haml within layouts/application (16.5ms)
Rendered client/_navigation.html.haml (1.5ms)
Rendered shared/_flash_messages.html.haml (0.3ms)
Completed 200 OK in 60ms (Views: 38.6ms | ActiveRecord: 6.4ms)

I've tried overriding the after_signup_path_for(resource_or_scope) but it seems to be getting ignored.

# app/controllers/application_controller.rb
def after_sign_up_path_for(resource_or_scope)
  random_path
end

So as it stands users can't register to the site in the first place. Any ideas?

Upvotes: 1

Views: 318

Answers (1)

Domness
Domness

Reputation: 7605

Have you checked to make sure non of your routes are overriding the default devise routes/methods?

Edited by HaaR for clarity of users with similar problem:

I had the following in my config/routes.rb above my devise_for methods.

match "client" => "wishes#index"

Which was overriding Devise's

devise_for :clients, :path => :client

By moving it below, it gives Devise priority, and still passes the get request to the appropriate controller and action without hijacking the POST requests.

Upvotes: 2

Related Questions