我正在使用Rails 4.2.5。我在我的「應用程序/視圖/佈局/ application.html.erb」文件這一行...如果我的用戶已登錄,如何包含其他文件?
<%= yield %>
如果用戶登錄,我想顯示在頁面中的內容「./app/ views/user_objects/index.html.erb「,但如果它們不是,我想顯示頁面」app/views/pages/_welcome.html.erb「中的內容。我不知道如何設置。在我的config/routes.rb中文件我有
constraints lambda { |req| !req.session[:user_id].blank? } do
root :to => 'user_objects#index', as: "dashboard"
end
root to: 'pages#index'
但顯示的是在任何時候都「./app/views/user_objects/index.html.erb」的文件,即使用戶沒有登錄。如果用戶未登錄,我需要添加(或刪除)哪些內容才能顯示正常的歡迎頁面內容?
您使用的設計進行登錄? – akz92