Code autogenerating

I’ve seen in my code lots of repeating code connected with
view(new/edit/
delete. I’d like to write an autogenerator of code (I’m going to base on
acts and scaffolding code).

Where in rails directory hierarchy should I put it?


I’ve probably left my head… somewhere. Please wait untill I find it.
Homepage (pl_PL): http://uzytkownik.jogger.pl/
(GNU/)Linux User: #425935 (see http://counter.li.org/)

Maciej P. wrote:

I’ve seen in my code lots of repeating code connected with view(new/edit/
delete. I’d like to write an autogenerator of code (I’m going to base on
acts and scaffolding code).

Where in rails directory hierarchy should I put it?

The first line of defense is “Refactoring” (with unit tests) to “DRY”
that
code up, where DRY means “Don’t Repeat Yourself”.

Ruby is so good at folding abstractions together, you ought to work to
get
that repeating code down to a few single lines. If you then actually
need to
generate the code, the common classes that you extracted should fit
perfectly inside it.

My Short Cut at O’Reilly has dozens of very effective techniques,
including
a few new assertions, to write unit tests for all kinds of View code,
not
just Ajax. The tests will make refactoring safe.


Phlip
http://www.oreilly.com/catalog/9780596510657/
“Test Driven Ajax (on Rails)”
assert_xpath, assert_javascript, & assert_ajax

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs