如何在rails上的ruby中创建向导表单 [英] how to create wizard forms in ruby on rails

查看:139
本文介绍了如何在rails上的ruby中创建向导表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图理解在rails上使用ruby的最佳选择。理想情况下,我希望拥有它,以便应用程序注册有一个后退和下一个按钮,允许用户逐步提交数据。



因此,在第1步中,他们可以填写出去联系信息。一旦他们完成,他们可以点击下一步,并在第2步填写付款信息等。如果他们犯了一个错误,他们可以点击返回并纠正它。有些步骤是必需的,而其他步骤则不需要,但您必须完成将数据提交到数据库注册的最后一步。然后他们需要有能力返回并在完成后以相同的方式填写过去的步骤。 (例如:如果他们点击了个人资料链接,他们可能会以相同的方式重新完成这些步骤,因为他们不想立即完成所有步骤。也许在完成注册步骤之前获得了跳过按钮? )。我还需要确认哪些步骤已经完成,防止他们进入下一步,直到纠正或完成。



选项1)我注意到ajax已经被推荐作为其他关于计算器的问题的一个选项。我遇到的唯一问题是,如果javascript被禁用,用户将无法注册。理想情况下,我希望它是原生的红宝石轨道上,但我愿意与任何必要的工作,以使其工作。

解决方案

有一些 plugins ,它提供了wizzard在rails中的构建方便。

充当向导 Wizardly 似乎最受欢迎。 >
主要想法是:

*在第一步创建一个模型

*然后在后续步骤中编辑它,

* apply对每个步骤进行部分验证,并且具有该模型的

*实现某种状态机。

I'm trying to understand the best options for pulling off a wizard form in ruby on rails. Ideally I'd like to have it so the application signup has a back and next button that allows the user to submit data in steps.

So in step 1 they could fill out contact info. Once they are done they could click next and be on step 2 to fill out payment info, etc. If they make a mistake, they can click back and correct it. Some steps will be required, while others will not, but you do have to make it to the last step to submit the data to the database to sign up. They then need the ability to go back and fill out the past steps in the same fashion after completion. (example: perhaps if they clicked on a profile link they could recomplete the steps in the same fashion because they didn't want to complete all the steps right away. Maybe by being given a skip button before they completed the steps to sign up?). I also need validation to happen on what steps have been completed preventing them from moving onto the next step until corrected or completed.

Option 1) I've noticed that ajax has been recommended as an option in other questions on stackoverflow. The only problem I have with it is that the user would not be able to sign up if javascript was disabled. Ideally I'd like to have it be native to ruby on rails but I'm willing to work with whatever is necessary to get it to work.

解决方案

There are a couple of plugins that provide wizzard construction facilitation in rails.
Acts as Wizard and Wizardly seem the most popular.
The main idea is to:
* create a model in the first step
* then edit it on subsequent steps,
* applying partial validation on each step and
* having the model implement some sort of state machine.

这篇关于如何在rails上的ruby中创建向导表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆