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