vlain wrote:
> After six month of development and a first release we decide to
> refactor our application. Since it was my first Ruby/Rails application
> there are a lot of horrible things inside it.

Next time, use TDD and refactoring as you go. You would have shipped much 
sooner, with fewer bugs.

> And now? Some general hints?

If you do not have unit tests (or "functional" tests, which are really just 
unit 
tests with a suggestive name), then do this:

  - start a new Rails project
  - pick the most important single _tiny_ feature in the old app
  - use TDD and refactoring to implement it int the new app
  - use the old app as a cheat sheet, but refrain from copying code out
  - repeat with each feature until done.

You will have a much cleaner application, with an exemplary design.

> I start with 2 simple questions:
> 1 - Where I put some common methods? Inside application.rb
> (controller) is ugly...

Refactor low hanging fruit. If your common methods have redundant lines that 
only talk about models, move them to models. Eventually your common methods 
will 
DRY up as if by themselves. Find the easiest possible refactors first - never 
attempt the hard ones while a bunch of easy ones are in the way. Eventually the 
hard ones will take care of themselves.

> 2 - In order to make skinny controller I write a lot of class method
> inside the model, maybe too much? Is this a common practice?

Yes - your models should fill up with lots of tiny methods, all apparently 
useless.

-- 
   Phlip


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to