I have been using Rails for some time (working on my first project now) and
I am wondering whether I am missing something obvious. There are so many
automatisms and conventions in the Rails code that there must be a way to
When I create a Model, I can specify restrictions and connections to other
class User < AR...
validates_length_of :name, :minimum => 5, :maximum => 10
1. When I decide to rename a column via a migration, is there a way to
automatically push this change through existing code? Say I want to
split "name" up into "surname" and "firstname". Do I really have to
manually dig through my code and do the replacement manually everywhere?
I could rig up an attr_accessor "name" that returns firstname + " " +
surname, but for unchanged scaffolds and controllers, I would expect a
rerun of "generate scaffold" (etc) to create the new "correct" scaffolds.
2. If I have an object (= database column) that has multiple restrictions,
and want to create a basic CRUD model, (how) can I autogenerate
2a. JS code that checks for e.g. format, length, etc. restrictions to be
OK using onSubmit()?
2b. AJAX code that checks for server-side restrictions (eg
uniqueness) "on-line", e.g. onBlur()?
2c. links to connected tables? E.g.:
- "User :has_many phonenumbers" should result in a link
"Add phonenumber" when editing the user, or similar)
- "User :has_one car" should result in an appropriate SELECT field
3. Can I easily design my own "default templates" for scaffolds and/or
trestles? Some default CSS and additional features would be nice and DRY.
So far, so good ... I'd appreciate any pointers or help on these.