Web和Mobile视图的最佳做法是相同的控制器或名称空间? [英] Web and Mobile views best practices same controller or namespace?

查看:102
本文介绍了Web和Mobile视图的最佳做法是相同的控制器或名称空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找有关开发具有常规视图和移动视图的Web应用程序的最佳实践的指南.移动版本的功能较少,但视图文件很多.

Im looking for the guidance on best practices for developing a web app with normal views and mobile views. The mobile version would have less of the functionality but a whole lot of view files.

将整个应用程序分为两个项目还是创建名称空间是更好的主意吗?还是简单地将所有内容保留在单个控制器中?

Is it a better idea to separate the whole application into two projects, or to create a namespace? Or simple to keep everything inside of the single set of controllers?

推荐答案

除非功能有很大不同,否则我将保持该应用程序的状态,并创建一个可显示移动网站页面的移动响应器.

Unless the functionality is drastically different, I'd leave the app as it is and create a mobile responder that would render the mobile site's pages.

respond_to :mobile { #render mobile view here }

之所以这样做,是因为您会将代码复制到另一个名称空间中,从而导致您对可维护性感到头疼.但是,如果功能非常不同,请继续为移动网站创建一个名称空间.

The reason for this is that you'd be copying code into another namespace and therefore causing yourself maintainability headaches. However, if the functionality is very different, go ahead and create a namespace for the mobile site.

这篇关于Web和Mobile视图的最佳做法是相同的控制器或名称空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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