Recommended workflow

Hi,

I've been programming in Ruby for a while (basic scripting tasks while working as syst. admin) and now I jumped to Rails and started developing some basic apps. I am quite famiIiar with MVC pattern, MySQL stuff and of course Git. I've been wondering if there is a recommended workflow to follow while developing with Rails.

Some questions come to mind: do you recommend to make a commit after applying a migration? Isn't a migration some kind of commit itself? I also know that some people begin with the view, then develop the model and in the end implement the controller, so what do you recommend?

Thank you!!

Some questions come to mind: do you recommend to make a commit after applying a migration? Isn't a migration some kind of commit itself?

While in general putting generated artifacts into a repo isn't usually a good idea, I always keep things like the schema in source control, so I do a commit after each migration is run. Personally I've been committing after creating the migration script and then after running it. It might make more sense to treat that as an atomic unit of work and make it a single commit, though.

I also know that some people begin with the view, then develop the model and in the end implement the controller, so what do you recommend?

Start with the cucumber/capybara test. Then create a route, then the simplest controller action and view to make the test pass. If there is any complexity to any of the above, write an rspec test first, then write the code to make it pass. If the controller has too much complexity, either get the tests passing and then refactor to the model, or possibly start with tests for a model object and then call it from the controller. For example, I needed to geocode addresses the other day and after writing the cucumber test, route and controller I immediately added a model object called location to wrap that complexity and rspec tests (with fakeweb and vcr) to ensure it worked as expected.

Best Wishes, Peter

One of the nice things about Rails Tutorial is that it teaches a workflow:

Also see:

http://blog.weiskotten.com/2009/04/my-git-workflow.html