Brian
Brian

Reputation: 6071

Rails Devise Override Registration Controller

I am working with Devise and I am trying to override the registrations controller.

I have followed posts on here with no luck.

This is what I have:

 class AccountsController::RegistrationsController < Devise::RegistrationsController
  def new
    super
  end
 end

   devise_for :accounts, :controllers => {:registrations => "accounts/registrations"} do
     get "welcome" => "accounts#new", :as => :new_account
   end

I also created an account folder in views and added the new view.

I receive the following error:

 app/controllers/accounts_controller.rb:1:in `<top (required)>'

Upvotes: 0

Views: 3609

Answers (2)

G SubbaRao
G SubbaRao

Reputation: 446

@Brian is correct it will work but you want your code have to work just change:

class AccountsController::RegistrationsController < Devise::RegistrationsController

to:

class Accounts::RegistrationsController < Devise::RegistrationsController

Then create an accounts folder in the controller folder and place this file to that folder.

Upvotes: 1

Brian
Brian

Reputation: 6071

Mine was a little different, but this solved the problem. Override devise registrations controller

  class RegistrationsController < Devise::RegistrationsController
def new
    @test = "test"
    super
end
  end

The I added the following to my views registrations/new.html.erb

Then:

  devise_for :accounts, :controllers => {:registrations => "registrations"} do
  get "welcome" => "registrations#new", :as => :new_account
  end

Upvotes: 0

Related Questions