links
300 Images From 1800 Sites
Punctuated Productivity
ascii table
brainjar.com: css positioning
Catman's Reference Guide to XHTML 1.1
Catman's XHTML 1.1 Elements and Attributes Reference Guide
citeseer
Color Scheme Generator
common errors in english
cool images
Copying music between authorized computers with iTunes for Windows
css layout-o-matic
daypop
del.icio.us
elegant hack
emacs wiki
floatutorial
imho...
keystroke shortcuts for windows xp
mozilla keyboard shortcuts
NameVoyager
perldoc.com
programming language popularity
regular expression tester
selectoracle
short url services
simple urls for search engines
the unix acronym list
yahoo dictionary
most read last 60 days: apache / fcgi / debian / rails (196)
installing ruby and rails on debian (157)
hard disk failure (127)
audiotron to audioscrobbler: atronscrobbler (124)
the lighter side: japanese error messages (118)
categories
cygwin / linux / unix
emacs
entertainment
government
health
restlater
ruby on rails
software development
system administration
textpattern
web technologies
sections
about
article
photos
portfolio
recently
Citizen’s Briefing Book
Tbone walking in the Park
rav this!
I'll rest later...
please don't feed the rails programmers
replication in rails
apache / fcgi / debian / rails
miguel's hell of gratuitous rewriting
favorite sig lines
listening reimplemented in ruby on rails
hard disk failure
maxloss
got backups?
installing ruby and rails on debian
hëävy mëtäl ümläüt
the lighter side: japanese error messages
home network performance
installing atronscrobbler on windows using cygwin
audiotron to audioscrobbler: atronscrobbler
lessons learned in electronic media
I’m working on a project that has 3 tables that are very similar and each should have a very similar edit UI. Of course I don’t want to duplicate code or coding effort if I don’t have to. I’m always trying to explore new areas of ruby and rails and this seemed like a good opportunity.
My first thought was to copy the scaffolding generator. I think most of the generators are pretty trivial but scaffolding is significant since it does reflection on the database in order to build the new and edit forms. Copying and modifying the scaffold generator was a bigger job than I expected but I got it working. Since the scaffold generator invokes the model generator I ended up modifying model too.
A modified generater is neat because you can make a change to the generator and completely regenerate the model, controller and views instantly.
I wasn’t satisfied with this though. Basically I now had a lot of automatically generated code. In addition I worked on it longer than if I had simply used the default scaffold generator and modified the forms and controllers individually.
It seemed to me that if you can run a generator 3 times you should be able to refactor things so that you only have one copy of that code instead of 3.
I wanted to experiment with run time code generation like rails associations (and many other features of rails). So I modified the controller adding a method that would generate other methods—the methods that are normally generated when you use scaffolding.
In the end I found that my 3 models were not as close as I had originally thought. The exceptions required to get these techniques to generate all of the code created a lot of complexity that started spilling out to other parts of the system.
Bottom line: these are useful tools to have in your back pocket especially if you are building plugins or other reusable code.
However, they probably should not be used in building a single application due to the additional complexity and non-standard application structure.
* * *