Permalink
Browse files

Using admin namespace

  • Loading branch information...
1 parent 3d6d216 commit 4b32482d64e24b4c25ff187bb77bfb9522efe4d9 @emerleite committed May 24, 2011
@@ -0,0 +1,3 @@
+class Admin::RegistrationsController < Devise::RegistrationsController
+
+end
@@ -0,0 +1,3 @@
+class Admin::SessionsController < ::Devise::SessionsController
+
+end
@@ -0,0 +1,8 @@
+class Admin::UsersController < ApplicationController
+ before_filter :authenticate_admin_user!
+
+ def show
+ @user = Admin::User.find(params[:id])
+ end
+
+end
@@ -1,5 +1,5 @@
class HomeController < ApplicationController
def index
- @users = User.all
+ @users = Admin::User.all
end
end
@@ -1,9 +0,0 @@
-class UsersController < ApplicationController
- before_filter :authenticate_user!
-
- def show
- @user = User.find(params[:id])
-
- end
-
-end
@@ -1,4 +1,4 @@
-class User
+class Admin::User
include Mongoid::Document
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
@@ -0,0 +1,9 @@
+<% if admin_user_signed_in? %>
+ <li>
+ <%= link_to('Logout', destroy_admin_user_session_path) %>
+ </li>
+<% else %>
+ <li>
+ <%= link_to('Login', new_admin_user_session_path) %>
+ </li>
+<% end %>
@@ -0,0 +1,9 @@
+<% if admin_user_signed_in? %>
+ <li>
+ <%= link_to('Edit account', edit_admin_user_registration_path) %>
+ </li>
+<% else %>
+ <li>
+ <%= link_to('Sign up', new_admin_user_registration_path) %>
+ </li>
+<% end %>
@@ -1,9 +0,0 @@
-<% if user_signed_in? %>
- <li>
- <%= link_to('Logout', destroy_user_session_path) %>
- </li>
-<% else %>
- <li>
- <%= link_to('Login', new_user_session_path) %>
- </li>
-<% end %>
@@ -1,9 +0,0 @@
-<% if user_signed_in? %>
- <li>
- <%= link_to('Edit account', edit_user_registration_path) %>
- </li>
-<% else %>
- <li>
- <%= link_to('Sign up', new_user_registration_path) %>
- </li>
-<% end %>
@@ -8,8 +8,8 @@
</head>
<body>
<ul class="hmenu">
- <%= render 'devise/menu/registration_items' %>
- <%= render 'devise/menu/login_items' %>
+ <%= render 'admin/menu/registration_items' %>
+ <%= render 'admin/menu/login_items' %>
</ul>
<%- flash.each do |name, msg| -%>
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
View
@@ -3,9 +3,10 @@
root :to => "home#index"
- devise_for :users
- resources :users, :only => :show
-
+ namespace :admin do
+ devise_for :users, :class_name => "Admin::User"
+ resources :users, :only => :show
+ end
# The priority is based upon order of creation:
# first created -> highest priority.
View
@@ -8,5 +8,5 @@
puts 'EMPTY THE MONGODB DATABASE'
Mongoid.master.collections.reject { |c| c.name =~ /^system/}.each(&:drop)
puts 'SETTING UP DEFAULT USER LOGIN'
-user = User.create! :name => 'First User', :email => 'user@test.com', :password => 'please', :password_confirmation => 'please'
+user = Admin::User.create! :name => 'First User', :email => 'user@test.com', :password => 'please', :password_confirmation => 'please'
puts 'New user created: ' << user.name

0 comments on commit 4b32482

Please sign in to comment.