Hello all,
As I''ve gotten more comfortable using rails, I''ve noticed some
things that I seem to be doing over and over. I think a fair number of the
issues I run across have come about because the default scaffolding
doesn''t quite do everything I want (although it is still pretty slick,
nonetheless). I know scaffolding isn''t supposed to be the final code,
but if I could do a few more things with it, I could probably keep more of what
gets generated. I wanted to run these items by the group before I try to write
scripts to handle them, as I imagine I''m probably not the first.
Here''s the issues:
1) The model generator doesn''t infer relationships with other tables -
it looks like it should be pretty straightforward to loop through the other
tables and look for cases where a) tablename_id is a field b) the current table
contains the name of another table and id and c) where another table contains
tablename_id and another table''s id. In other words, I''d like
it to infer the a) has_many b) belongs_to c)has_and_belongs_to_many
relationships.
2) The code that generates the list view should:
a) Loop through the table fields at generation time, rather than runtime.
b) It should be smart enough to take any foreign key fields and make them
point to a more descriptive value (in other words, it should pull back the name
property from Customer instead of Customer_id when displaying an invoice).
c) The table should be given an appropriate CSS class, as should the
headers, data fields, etc.
3) The code that generates the fields for the edit/list view should be improved
by:
a) If it sees something that appears to be a foreign key to another table,
it should automatically generate a dropdown control for selecting the value in a
more friendly way. You could have it pull in the name field automatically, for
example.
b) If it sees a boolean field, it should generate a checkbox
c) If it sees a field named password, it should automatically make it a
password textbox
d) Would it be possible to make it load the associated model class
dynamically as the script is running? If so, it might be possible to determine
the items that are contained by object (has_many relationships) and provide UI
for them. You might even be able to do the same for has_and_belongs_to_many
relationships.
e) Long text fields should automatically get a Text Area control
f) Fields should be enclosed in a fieldset, with an appropriate CSS class
set for the fieldset and an appropriate legend (no underscores)
g) Field labels should be actual labels, with the "for" attribute
set for accessibility.
Does anyone have anything else they would add? Does anyone have fixes for the
stuff I just listed?
Thanks,
Will
---------------------------------
Get the Yahoo! toolbar and be alerted to new email wherever you''re
surfing.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---