简体   繁体   English

Rails方式-如何向课程添加注册-课程控制器或侧倾控制器?

[英]rails way - how to add enrollment to course - course controller or roll controller?

I have a course model and a roll model (which points to the course and to the student). 我有一个课程模型和一个滚动模型(指向课程和学生)。

course has many rolls
roll belongs to course
roll belongs to student

When viewing a visitor record (attended a class but not on the roll [attendance and event models not pertinent]) I want to be able to click a button to enroll them in the course and then take them to the edit view of the enrollment record (for specifying type of enrollment and any notes). 查看访客记录时(出席课堂但不在课堂上[不涉及出勤和事件模型])我希望能够单击一个按钮将其注册到课程中,然后将其带到注册记录的编辑视图中(用于指定注册类型和任何注释)。

Adding a student to a course... controllers... should I have a method on the course to add the roll record or should I have a method on the roll? 正在将学生添加到课程中...控制器...我应该在课程中使用某种方法来添加滚动记录还是应该在课程中使用一种方法? After the record is created the controller should redirect to the rolls#edit. 创建记录后,控制器应重定向到rolls#edit。

I'm somewhat of a rails newbie and want to make sure I'm doing this the right way/rails way. 我有点像Rails的新手,并且想要确保我以正确的方式/ rails的方式进行操作。 And I'm sure this type of question has been asked before, but my searches avail me naught-- I'm sure I'm not searching the right phrases. 而且我敢肯定这种类型的问题已经被问过了,但是我的搜索却无济于事-我确定我没有搜索正确的短语。

I would link that button to RollsController#create. 我会将那个按钮链接到RollsController#create。 The other option you might be considering is CoursesController#update, but you're not really changing anything about the course itself, like its name, number of credits, or anything intrinsic to the course. 您可能正在考虑的另一种选择是CoursesController#update,但是您并没有真正更改课程本身的任何内容,例如课程名称,学分数或课程固有的内容。

You're creating a new instance of an enrollment: a student in a course. 您正在创建一个新的注册实例:一个课程中的学生。 RollsController#create. RollsController#create。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM