1

Rails 3.2.13devise 2.2.3을 사용하여 로그인하고 대시 보드에 입장 할 수있는 일반 사용자가 있습니다. 내가 devise로 다른 사용자를 만들고 별도의보기, 컨트롤러 및 모델로 만들었을 때, 같은 방식으로 작동하지 않습니다. 나는 심지어 user와 같은 방식으로 user1 연관을 모델링했다. 이제는 문서를 읽는 데 너무 많은 어림짐작을 사용하여 뭔가를 놓치고 있다는 것을 이해합니다. 그러나 어떻게 든 그것을 성취하지 못합니다. user1은 가입 절차를 거쳤지만 가입시 집으로 리디렉션됩니다. 기밀 사용자 범위 지정

Started POST "/user1" for 127.0.0.1 at 2014-06-03 10:58:58 +0530 
Processing by Devise::RegistrationsController#create as HTML 
    Parameters: {"utf8"=>"✓", "authenticity_token"=>"yjG8AroaqqhCeyW9IDMNYHPV4+brvbdA3IlFNdf4Ecw=", "user1"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"} 
    (0.3ms) BEGIN 
    User1 Exists (48.8ms) SELECT 1 AS one FROM "user1" WHERE ""."email" = '[email protected]' LIMIT 1 
    user1 Load (25.8ms) SELECT "user1".* FROM "user1" WHERE "user1"."confirmation_token" = 'vzwnRygWM6HiPezPfPfq' LIMIT 1 
    SQL (70.6ms) INSERT INTO "user1" ("confirmation_sent_at", "confirmation_token", "confirmed_at", "created_at", "current_sign_in_at", "current_sign_in_ip", "email", "encrypted_password", "last_sign_in_at", "last_sign_in_ip", "name", "remember_created_at", "reset_password_sent_at", "reset_password_token", "role", "sign_in_count", "unconfirmed_email", "updated_at", "verified", "verified_by_admin") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20) RETURNING "id" [["confirmation_sent_at", Tue, 03 Jun 2014 05:28:59 UTC +00:00], ["confirmation_token", "vzwnRygWM6HiPezPfPfq"], ["confirmed_at", nil], ["created_at", Tue, 03 Jun 2014 05:28:59 UTC +00:00], ["current_sign_in_at", nil], ["current_sign_in_ip", nil], ["email", "[email protected]"], ["encrypted_password", "$2a$10$kwhkGjNd9ocZ3t.WUUZB4uGXFnpoDao9rHLD5rlEUR/iO0mVWQ1gS"], ["last_sign_in_at", nil], ["last_sign_in_ip", nil], ["name", ""], ["remember_created_at", nil], ["reset_password_sent_at", nil], ["reset_password_token", nil], ["role", nil], ["sign_in_count", 0], ["unconfirmed_email", nil], ["updated_at", Tue, 03 Jun 2014 05:28:59 UTC +00:00], ["verified", nil], ["verified_by_admin", nil]] 
    Rendered user1/mailer/confirmation_instructions.html.erb (0.8ms) 

Sent mail to [email protected] (63ms) 
Date: Tue, 03 Jun 2014 10:58:59 +0530 
From: [email protected] 
To: [email protected] 
Message-ID: <538d5d1b7df6a[email protected]> 
Subject: Confirmation instructions 
Mime-Version: 1.0 
Content-Type: text/html; 

<p>You can confirm your account email through the link below:</p> 

<p><a href="">Confirm my account</a></p> 

Sent mail to [email protected] (2ms) 
Date: Tue, 03 Jun 2014 10:58:59 +0530 
To: [email protected] 
Message-ID: <[email protected]> 
Subject: Sign Up Confirmation 
Mime-Version: 1.0 
Content-Type: text/plain; 
charset=UTF-8 
Content-Transfer-Encoding: 7bit 


    (53.7ms) COMMIT 
Redirected to http://localhost:3000/ 
Completed 302 Found in 882ms (ActiveRecord: 0.0ms) 


Started GET "/" for 127.0.0.1 at 2014-06-03 10:58:59 +0530 
Processing by HomeController#index as HTML 
    Rendered application/_cta.html.erb (0.0ms) 
    Rendered home/index.html.erb within layouts/application (2.7ms) 
    Rendered application/_header.html.erb (0.5ms) 
    Rendered application/_footer.html.erb (0.8ms) 
Completed 200 OK in 67ms (Views: 66.1ms | ActiveRecord: 0.0ms) 

내가 USER1에 대해 동일한을 달성 할 수있는 방법 나를 인도 마십시오

devise_for :user1 
    match 'user1/sign_up' => 'user1#new' 
    match 'user1/dashboard' => 'user1#dashboard' 

로그

경로 : 다음

는 세부 사항의 일부, 더 물어 제공 될 것입니다 , 그리고 사용자 1에 대해 개발 된 것과 동일한 것을 사용자 1에게 어떻게 범위를 매기 는가?

답변

0

devise 문서에 따르면 모델에 대해 범위가 지정된 경로를 만들 수 있습니다. 기본적으로 devise는 범위가 지정된 root_path를 먼저 찾고, 존재하지 않으면 기본 루트로 리디렉션합니다.

범위가 지정된 루트 경로는 다음과 같습니다 "# {devise_model_name} _root_path"

사건에 대한 다음과 같은 예를 생각해 궁리 문서의 Controller filter and Helper 섹션에서

get 'user1/dashboard', :to => 'user1#dashboard', :as => :user1_root 

더 많은 정보를.

희망이 도움이됩니다.