Reputation: 27232
I decided to make a RegistrationsController so I can redirect the user on sign up to a specific page. Only problem is the user doesn't even get created because I get the error:
Started POST "/users" for 127.0.0.1 at 2012-06-12 14:01:22 -0400
AbstractController::ActionNotFound (The action 'create' could not be found for R
egistrationsController):
My routes and controller:
devise_for :users, :controllers => { :registrations => "registrations" }
devise_scope :user do
get "/sign_up" => "devise/registrations#new"
get "/login" => "devise/sessions#new"
get "/log_out" => "devise/sessions#destroy"
get "/account_settings" => "devise/registrations#edit"
get "/forgot_password" => "devise/passwords#new", :as => :new_user_password
get 'users', :to => 'pages#home', :as => :user_root
end
class RegistrationsController < ApplicationController
protected
def after_sign_up_path_for(resource)
redirect_to start_path
end
def create # tried it with this but no luck.
end
end
What's going on here? How is this fixed?
UPDATE
I put the create
action outside of protected
but now I get a Missing template registrations/create
. Remove the action brings me back to Unknown action: create
.
Upvotes: 2
Views: 4675
Reputation: 18203
It looks like the problem is with the way you've set up your RegistrationsController
. If you take a look at the Devise wiki page explaining how to do this, you'll see the following example:
class RegistrationsController < Devise::RegistrationsController
protected
def after_sign_up_path_for(resource)
'/an/example/path'
end
end
Note that the RegistrationsController
is inheriting from Devise::RegistrationsController
rather than ApplicationController
. This is done so that your custom controller is inheriting all the correct behavior from Devise, including the create
action.
Upvotes: 5
Reputation: 239511
Your create
method is protected
, meaning it can't be routed to.
Move your create
method out of your protected
methods:
class RegistrationsController < ApplicationController
def create
end
protected
def after_sign_up_path_for(resource)
redirect_to start_path
end
end
Upvotes: 6