Search code examples
ruby-on-railsbusiness-logic

Where does business logic go in rails?


I'm an ASP.NET MVC developer just starting with my first big project on rails however Im confused as where to put your business logic? on ASP.NET I create a library which contains services(Domain driven design) which handle business logic, I have heard that rails uses a concept of fat model skinny controller but I have some projects in ASP.NET which adding all the logic to the controller would create a big mess, is there any other way?


Solution

  • Go with the concept of FatModels and SkinnyControllers. Your models should know how they behave and what they should do.

    When your models get too fat, extract them out into re-usuable modules and include them in your module.

    You can easily test behavior of models using RSpec (or test/unit or shoulda). Then you can test that the application behaves correctly using Cucumber.