是否有可能改变一个Rails项目的文件夹结构? [英] Is it possible to alter the folder structure in a Rails project?

查看:152
本文介绍了是否有可能改变一个Rails项目的文件夹结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从.NET MVC背景希望做RoR中的一个项目来了。具体来说,我开发一个REST API。

我将介绍我的想法,希望你能引导我在正确的方向。我的API必须支持版本和版本的API是复制code为每个版本的最可靠的方法。在一个版本的方式固定的问题不会影响其他版本。当谈到这样做在.NET MVC,领域是你最好的朋友,因为每个版本的源文件可以很好地通过使用区域被分割。

所以我的问题是:在回报率是有可能改变的目录结构,使该层次结构

 应用程序/
  控制器
    / V1
      c1_controller.rb
      c2_controller.rb
    / V2
      c1_controller.rb
      c2_controller.rb
  楷模/
    / V1
      m1.rb
      m2.rb
    / V2
      m1.rb
      m2.rb
  意见/
    / V1
      view1.html.erb
      view2.html.erb
    / V3
      view1.html.erb
      view2.html.erb

可以重新排列来呢?

 应用程序/
  V1 /
    控制器/
      c1_controller.rb
      c2_controller.rb
    楷模/
      m1.rb
      m2.rb
    意见/
      view1.html.erb
      view2.html.erb
  V2 /
    控制器/
      c1_controller.rb
      c2_controller.rb
    楷模/
      m1.rb
      m2.rb
    意见/
      view1.html.erb
      view2.html.erb


解决方案

我想你可能试图解决在稍微放错了地方你的问题。如果你需要同时支持应用程序的多个版本,并能够使修复他们独立等等等等,用git进行版本控制(如果你没有的话),并创建为每个版本单独的分支听起来像的方式去给我。 (我敢肯定,你可以做类似与Mercurial,SVN等,但Git的似乎是Rails的事实上的标准)。

下面是约分支的一些信息的链接: HTTP ://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging

I'm coming from the .Net MVC background looking to do a project in RoR. Specifically I'm develop a REST api.

I will describe my thinking and hopefully you could steer me in the right direction. My api must support versions and the most robust way to version an api is to duplicate the code for every version. That way fixing issues in one version doesn't effect other versions. When it comes to doing that in .NET MVC, areas are your best friend because source files for each version can nicely be segmented through using areas.

So my question is: In RoR is it possible to change the directory structure so this hierarchy

app/
  controllers
    /v1
      c1_controller.rb
      c2_controller.rb
    /v2
      c1_controller.rb
      c2_controller.rb
  models/
    /v1
      m1.rb
      m2.rb
    /v2
      m1.rb
      m2.rb
  views/
    /v1
      view1.html.erb
      view2.html.erb
    /v3
      view1.html.erb
      view2.html.erb

can be rearranged to this?

app/
  v1/
    controllers/
      c1_controller.rb
      c2_controller.rb
    models/
      m1.rb
      m2.rb
    views/
      view1.html.erb
      view2.html.erb
  v2/
    controllers/
      c1_controller.rb
      c2_controller.rb
    models/
      m1.rb
      m2.rb
    views/
      view1.html.erb
      view2.html.erb

解决方案

I think you may be trying to solve your problem in slightly the wrong place. If you need to support several versions of your application simultaneously, and be able to make fixes to them independently etc etc, using git for your version control (if you're not already) and creating a separate branch for each version sounds like the way to go to me. (I'm sure you could do similar with Mercurial, SVN etc but Git does seem to be the Rails de facto standard).

Here's a link to some info about branching: http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging

这篇关于是否有可能改变一个Rails项目的文件夹结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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