Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

How To: Customize routes to user registration pages

george edited this page · 2 revisions
Clone this wiki locally

Imagine we have the following devise users Customer::Private and Customer::Public.

# models/customer/private.rb
# models/customer/public.rb

Setting up the controllers

In order to scope the actions of each type of user, we first create the following controllers:

# app/controllers/customer/private/registrations_controller.rb
class Customer
  class Private
    class RegistrationsController < Devise::RegistrationsController
    end
  end
end

Setting up the views

You will then have to create views for these, for example:

# views/customer/private/registrations/new.html.haml
# views/customer/public/registrations/new.html.haml

You will likely want to have a _form.html.haml partial for each.

Configuring the devise registration routes

Then in the routes file

  devise_for :private_customers, :class_name => 'Customer::Private', :controllers => {:registrations => "customer/
private/registrations", :sessions => 'main' } do
    get   "private_customer/sign_up" => "customer/private/registrations#new", :as => :private_customer_signup
    get   "private_customer/sign_in" => "main#index", :as => :private_customer_signin
  end

Similarly for public customer. Then you are ready to hit it from the view, as link_to 'register', private_customer_signup_path in the view. Enjoy!

Something went wrong with that request. Please try again.