开发者

How do I setup a Rails view without knowing specifics about the form_for?

I'm building a workflow for a Rails app in which a user logs into the system, and on the home page to the app a supervisor selects a student and a tutor who the student spent time. Then they submit the form. This should all happen on the app's home page. My problem is since开发者_StackOverflow社区 it is not known when you go to that page who the specific student is, and thus who this form is for, it's not obvious to me how to setup the view and controller for this page.

Perhaps the form is for the lesson, but I've got a document (MongoDB) data model in which the lesson is embedded within the student document.

I could imagine a workflow where the user sees a list of students on the home page, and then clicks on the student to go to the model/controller for that specific student, and then enters the lesson's info there, but I'm trying to avoid unnecessary clicks and screens if possible.

Is my data model wrong? Is there a way to build this and keep my current data model? Is there a Rails pattern or helper that I should be aware of?

Thanks, Bob.


When you build a workflow, you usually have one of your controllers behave as an orchestrator, and that controller sends the user to the right page.

Since you only want one form to send a user to 2 potential pages, you could post the form to a controller (a controller called "search" for example), and that controller decides weather to redirect the user to one of the two views, with the necessary parameters in the url (such as student_id, tutor_id or lesson_id).

And please work on your accept rate, you won't get many responses otherwise.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜