Search code examples
ruby-on-railsrubyruby-on-rails-3devise

Devise uninitialize constant Users


I realize this has been asked many times on here (I also read through the wiki). But I am still confused at how to properly keep my route names the same.

Currently my devise routes are below, using custom url's (for example /user/signup).

My model is called User

Routes:

  devise_for :users, :controllers => { :registrations => "registrations" }, :path_names => {
    :sign_up => 'signup'
  }

  devise_for :users, :path => "user", :except => "create", :path_names => { 
    :sign_in  => 'login', 
    :sign_out => 'logout', 
    :password => 'forgot-password', 
    :confirmation => 'verification', 
    :unlock   => 'unblock', 
    :sign_up  => 'signup' 
  } 

All I am trying to do is hook into the create action so I can check if a honeypot field I have created is filled out (to prevent spam). That's really all I want to do.

I want to keep my url the same though /user/signup. Is there an extra step I need to do?

This is what I have so far in...

/app/controllers/registrations_controller.rb

class Users::RegistrationsController < Devise::RegistrationsController

  def new
    super
  end

  def create
    super
  end

end   

I am getting uninitialized constant Users


Solution

  • Quite simply I needed to put the controller in a 'users' folder, and that fixed everything. (Also, the route controller needs to be :registrations => "users/registrations"