在我的问题中,如何在用户未登录 Rails 时拥有 root 视图?max 回答说,authenticated只有当某人通过身份验证时,我们才能使用路由。我有一个问题,我该如何构建这个:
Rails.application.routes.draw do
devise_for :users
authenticated :user do
# when authenticated allow all action on student
resources :subjects do
resources :students
end
end
# when not only allow read on student
resources :subjects do
resources :students, only: [:get]
end
root "home#index"
end
Run Code Online (Sandbox Code Playgroud)
问题是我不想允许任何未经身份验证的操作:subjects来阻止它?