2014-09-11 118 views
1

我已經按照本教程進行了授權:https://www.railstutorial.org/book/sign_in_out#cha-sign_in_sign_out但現在我想將子域添加到我的應用程序中。沒有路線匹配[GET]會話

我已經添加到了我的routes.rb

match '/' => 'students/board', :constraints => { :subdomain => 'student' }, via: 'get' 

如果我想在重定向符號後用戶自己的子域這樣的:

redirect_to :subdomain => 'student', :path => '/' 

我得到這個錯誤:

No route matches [GET] "/sessions" 

如果我重定向用戶沒有子域名,他通常是重定向。我不明白爲什麼它試圖獲得'會話'路徑。我會感謝一些建議。我沒有發現任何與登錄會話和子域相關的在線內容。

謝謝!

+0

你有一個會話路由某處定義? – Deekor 2014-09-11 01:04:57

+0

@Deekor,不,不需要。如果我不放':subdomain =>'student',那麼所有的東西都可以工作。 – user3304086 2014-09-11 01:09:27

回答

0

您的代碼中可能有些東西沒有顯示我們將您重定向到會話路徑。

您是否嘗試命名該路徑,然後重定向到那裏?

的routes.rb:

get '/' => 'students/board', :constraints => { :subdomain => 'student' }, as: 'student_login' 

然後使用:

redirect_to student_login_path 
+0

感謝您的建議。我在這篇教程中沒有什麼不同。我只是c/p的一切。這通常會登錄用戶,但不會顯示子域。 – user3304086 2014-09-11 01:21:31