ruby - Two sign_in forms each on own url in rails devise -


its possible create 2 sign in views / 2 forms each on own urls in devise ? need 1 web administrator (back administration) , 1 users (application), 1 model (with roles)

  1. web administration / admin.domain.tld/login
  2. user application / app.domain.tld/login

(after unsucessful sign in must stay on url admin on admin.domain.tld/login , , user on app.domain.tld/login)

is possible ? how ?

i have it

controllers/admin/sessions_controller.rb

class admin::sessionscontroller < devise::sessionscontroller end 

controllers/app/sessions_controller.rb

class app::sessionscontroller < devise::sessionscontroller end 

views/admin/sessions/new.html.erb

<%= simple_form_for(resource, :as => resource_name, url: admin_login_path) |f| %>     <div class="form-inputs">       <%= f.input :email, :required => false, :autofocus => true %>       <%= f.input :password, :required => false %>     </div>      <div class="form-actions">       <%= f.button :submit, "sign in" %>     </div> <% end %> 

views/app/sessions/new.html.erb

<%= simple_form_for(resource, :as => resource_name, url: app_login_path) |f| %>     <div class="form-inputs">       <%= f.input :email, :required => false, :autofocus => true %>       <%= f.input :password, :required => false %>     </div>      <div class="form-actions">       <%= f.button :submit, "sign in" %>     </div> <% end %> 

config/routes.rb

  namespace :app     devise_for :users      devise_scope :app_user       'login' => 'sessions#new'       post 'login' => 'sessions#create'     end   end    namespace :admin     devise_for :users      devise_scope :admin_user       'login' => 'sessions#new'       post 'login' => 'sessions#create'     end   end 

all works fine, possible add :constraints => {:host => "domain"} , edit routes desired url's


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -