Reputation: 609
What is best way to refactor in Ruby on Rails. I have a project where i would like to refactor several of my objects - extra properties and renaming of existing properties. How do i do this this the easiest way?? I created the different objects with scaffolding "rails generate scaffold foo name:string...." I do start from scratch or is there some cool ruby command, like "rails refactor foo name:string"..
Upvotes: 0
Views: 606
Reputation: 10053
Firstly a good knowledge of your application and then start in a procedure and serialize it.
Thanx
.
Upvotes: 0
Reputation: 83680
You should learn some Rails best practices and use them to refactor your code
Upvotes: 1
Reputation: 4747
As far as I am aware, there is no automated way to do this. The key things as far as I'm concerned is to make sure that your test coverage is good in the relevant area (and preferably across your whole app) before you start.
Once that's done, I've tended to apply fairly brute force tactics to do that actual refactor:
The reason that refactoring isn't very automated in Ruby (in my view at least) is because the language is so dynamic, so it's very hard for any automated tools to make sure they've covered all the bases.
Upvotes: 2
Reputation: 18220
Refactoring is based on human perception. Sure, omission of some redundant things could be figured out by a computer, but otherwise when you refactor you're essentially improving your own hand-written code. Unless a computer has the intelligence and the ability to discern code like a human, then no, it's not possible.
Perhaps you're referring to something else?
Upvotes: 1