我正在设置我的第一个rails应用程序,我有一个经验丰富的开发人员的问题。我使用设计用于我的用户身份验证系统。我还没有接受这个措辞,所以请原谅我。
用户登录时将有一个仪表板。使用生成脚手架工具为仪表板设置单个控制器(并使用if语句进行区分)或创建/ students下的仪表板页面是否更好? /老师(有两个独立的控制员)?
我希望避免浪费时间或不得不回溯我的应用程序,如果我注意到一种方法不会让我在未来取得成功。我倾向于将它们分开。
以下是我的佣金路线,供您查看我到目前为止的设置:
rake routes
Prefix Verb URI Pattern Controller#Action
landing_index GET /landing/index(.:format) landing#index
new_teacher_session GET /teachers/sign_in(.:format) devise/sessions#new
teacher_session POST /teachers/sign_in(.:format) devise/sessions#create
destroy_teacher_session DELETE /teachers/sign_out(.:format) devise/sessions#destroy
teacher_password POST /teachers/password(.:format) devise/passwords#create
new_teacher_password GET /teachers/password/new(.:format) devise/passwords#new
edit_teacher_password GET /teachers/password/edit(.:format) devise/passwords#edit
PATCH /teachers/password(.:format) devise/passwords#update
PUT /teachers/password(.:format) devise/passwords#update
cancel_teacher_registration GET /teachers/cancel(.:format) devise/registrations#cancel
teacher_registration POST /teachers(.:format) devise/registrations#create
new_teacher_registration GET /teachers/sign_up(.:format) devise/registrations#new
edit_teacher_registration GET /teachers/edit(.:format) devise/registrations#edit
PATCH /teachers(.:format) devise/registrations#update
PUT /teachers(.:format) devise/registrations#update
DELETE /teachers(.:format) devise/registrations#destroy
new_student_session GET /students/sign_in(.:format) devise/sessions#new
student_session POST /students/sign_in(.:format) devise/sessions#create
destroy_student_session DELETE /students/sign_out(.:format) devise/sessions#destroy
student_password POST /students/password(.:format) devise/passwords#create
new_student_password GET /students/password/new(.:format) devise/passwords#new
edit_student_password GET /students/password/edit(.:format) devise/passwords#edit
PATCH /students/password(.:format) devise/passwords#update
PUT /students/password(.:format) devise/passwords#update
cancel_student_registration GET /students/cancel(.:format) devise/registrations#cancel
student_registration POST /students(.:format) devise/registrations#create
new_student_registration GET /students/sign_up(.:format) devise/registrations#new
edit_student_registration GET /students/edit(.:format) devise/registrations#edit
PATCH /students(.:format) devise/registrations#update
PUT /students(.:format) devise/registrations#update
DELETE /students(.:format) devise/registrations#destroy
root GET / landing#index
再说一遍,您认为让学生的仪表板和教师的仪表板分开,或者只有一个仪表板并使用if语句来区分基于用户的类型(使用0& 1表示他们是学生还是教师)?
提前致谢!
答案 0 :(得分:1)
如果要向每种类型的用户显示的数据相似,则可以使用相同的控制器并根据用户的类型加载不同的部分。