如何创建MVC下一个简洁和REST风格的精灵? [英] How do I create a concise and RESTful wizard under MVC?

查看:93
本文介绍了如何创建MVC下一个简洁和REST风格的精灵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着尽可能在构建应用程序,但有一件事我从来没有肯定的是如何创建一个向导式工作流程,是REST风格,简洁的REST风格。

I try to be as RESTful as possible in building applications but one thing that I'm never sure about is how to create a wizard-type work flow, be RESTful and concise.

举个例子,一个多页的注册过程。

Take, for example, a multi-page sign-up process.

选项1:我可以为每一个步骤一个控制器,当用户到达那一步(或回吧)调用新的或编辑。我结束与step1_controller,step2_controller,等等...

Option 1: I can create a controller for each step and call new or edit when user gets to that step (or back to it). I end with step1_controller, step2_controller, etc...

选项2:我可以创建一个控制器和跟踪,他们是在注册过程有一个参数,会话变量,状态机 - 不管。所以我有signup_controller /步?ID = 1

Option 2: I can create a one controller and track where they are in the sign-up process with a param, session variable, state-machine - whatever. So I'd have signup_controller/step?id=1

第一种选择是严格的休息,但不是非常简洁,并与一些额外的数控制器结束。第二个选项是更简洁,但休息休息,这我很愿意这样做,但我不掉以轻心。

The first option is strictly REST, but not very concise and ends with some number of extra controllers. The second options is more concise, but breaks REST, which I'm willing to do, but I don't take it lightly.

有没有更好的选择?

我在工作的Ruby on Rails的,但这个问题也适用于其他MVC实现,如ASP.NET MVC

I'm working in ruby on rails, but this question applies to other MVC implementations, like ASP.NET MVC

推荐答案

我其实是不太关心的一次性向导维护REST。 REST是最重要的,我认为,有重复的动作 - 你想,让你找回数据相同的观点,无论当你去那里的网址是基本可收藏。在一个多步骤的向导,你有打算无论如何要打破REST的这个角度依赖。我的感觉是有可能与单独的操作或使用查询参数,表明你是哪一步一个控制器。这是我一直反正我结构性激活向导(这需要多个步骤)。

I'm actually less concerned about maintaining REST in a one-shot wizard. REST is most important, I think, with repeatable actions -- you want the url to be basically bookmarkable so that you get back the same view of the data regardless of when you go there. In a multi-step wizard you have dependencies that are going to break this perspective of REST anyway. My feeling is to have a single controller with potentially separate actions or using query parameters to indicate what step you are on. This is how I've structured my activation wizards (which require multiple steps) anyway.

这篇关于如何创建MVC下一个简洁和REST风格的精灵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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