Maciej Piechotka 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
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---