I would like to find a simple way of generating the code to list, add, update and delete data from some legacy MySQL tables. I''ve played around with the scaffold and although it is impressive it doesn''t quite suit my needs. (Of course it doesn''t, it''s meant to help me build out my app, but what I mean is I''m looking for some more ways to automate things that I know I''ll be doing for every app.) Almost every app I build has an administrative interface. These interfaces all look the same, have the same style sheets, have the same login functionality and are used to manage data in tables that are used in a public website. They usually have different sets of tables to manage depending on the nature of the public app, along with a set of tables and static data that is the same all the time (administrators, administrator_types, etc). In my PHP framework I keep meta data about the tables in an XML file, and the framework uses that to determine what what should happen for each field in each table in the interface. For example, which fields should be in the list view or edit view, the level of admin that can modify a field, whether or not a field is required, the error message if the field does not validate, the tooltip for a field, if a field is storing path to an image so on add the ''image upload'' functionality pops up in edit/add, and so on. I''ve found this approach a nice way to keep things tidy in one file. So I''d like to find a similar way to automate the task of building administrative interfaces in Rails, instead of running scaffolding for every table and then adding all of the other bells and whistles I will need. I''m thinking I''ll probably have to build my own generator and have it work off of meta information in a YAML file. Is this the right approach? If so, should the generator do this up front and create code from the YAML file or should the generator create code that references the YAML file (for example, at the top of a model the YAML file is read and the validation needed for each model is declared). I''m new to Ruby, Rails and MVC so I thought I would submit my thinking here for comments and suggestions.
On 9/15/05, cleaner416 <cleaner416-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I would like to find a simple way of generating the code to list, > add, update and delete data from some legacy MySQL tables. I''ve > played around with the scaffold and although it is impressive it > doesn''t quite suit my needs. (Of course it doesn''t, it''s meant to > help me build out my app, but what I mean is I''m looking for some > more ways to automate things that I know I''ll be doing for every app.) > > Almost every app I build has an administrative interface. These > interfaces all look the same, have the same style sheets, have the > same login functionality and are used to manage data in tables that > are used in a public website. They usually have different sets of > tables to manage depending on the nature of the public app, along > with a set of tables and static data that is the same all the time > (administrators, administrator_types, etc). In my PHP framework I > keep meta data about the tables in an XML file, and the framework > uses that to determine what what should happen for each field in each > table in the interface. For example, which fields should be in the > list view or edit view, the level of admin that can modify a field, > whether or not a field is required, the error message if the field > does not validate, the tooltip for a field, if a field is storing > path to an image so on add the ''image upload'' functionality pops up > in edit/add, and so on. I''ve found this approach a nice way to keep > things tidy in one file. > > So I''d like to find a similar way to automate the task of building > administrative interfaces in Rails, instead of running scaffolding > for every table and then adding all of the other bells and whistles I > will need. I''m thinking I''ll probably have to build my own generator > and have it work off of meta information in a YAML file. > > Is this the right approach? If so, should the generator do this up > front and create code from the YAML file or should the generator > create code that references the YAML file (for example, at the top of > a model the YAML file is read and the validation needed for each > model is declared). > > I''m new to Ruby, Rails and MVC so I thought I would submit my > thinking here for comments and suggestions.Sounds good to me. I''d write a generator that would read the YAML file, and then create the models, controllers, and views. Although, you might find that in Rails, it shouldn''t be as difficult as it was in PHP to manually enter the data into the models/controllers/views.
Have a look at BoilerPlate! http://www.schuerig.de/michael/boilerplate/ Greetz, Martin cleaner416 wrote:> I would like to find a simple way of generating the code to list, > add, update and delete data from some legacy MySQL tables. I''ve > played around with the scaffold and although it is impressive it > doesn''t quite suit my needs. (Of course it doesn''t, it''s meant to > help me build out my app, but what I mean is I''m looking for some > more ways to automate things that I know I''ll be doing for every app.) > > Almost every app I build has an administrative interface. These > interfaces all look the same, have the same style sheets, have the > same login functionality and are used to manage data in tables that > are used in a public website. They usually have different sets of > tables to manage depending on the nature of the public app, along > with a set of tables and static data that is the same all the time > (administrators, administrator_types, etc). In my PHP framework I > keep meta data about the tables in an XML file, and the framework > uses that to determine what what should happen for each field in each > table in the interface. For example, which fields should be in the > list view or edit view, the level of admin that can modify a field, > whether or not a field is required, the error message if the field > does not validate, the tooltip for a field, if a field is storing > path to an image so on add the ''image upload'' functionality pops up > in edit/add, and so on. I''ve found this approach a nice way to keep > things tidy in one file. > > So I''d like to find a similar way to automate the task of building > administrative interfaces in Rails, instead of running scaffolding > for every table and then adding all of the other bells and whistles I > will need. I''m thinking I''ll probably have to build my own generator > and have it work off of meta information in a YAML file. > > Is this the right approach? If so, should the generator do this up > front and create code from the YAML file or should the generator > create code that references the YAML file (for example, at the top of > a model the YAML file is read and the validation needed for each > model is declared). > > I''m new to Ruby, Rails and MVC so I thought I would submit my > thinking here for comments and suggestions.
Ages ago there was a post on this list by Derek from CD Baby (20 July - "shared controllers in Rails") and he posted this: http://dereksivers.com/rails-shared-controller.html which I found to be useful as a starting point for shared infrastructure. I only use it for the relatively simple stuff but it has really saved me from a lot of bloat from scaffold. HTH, Dan
This is a great little piece of recommended reading for newcomers - as a relative Rails newbie I found it enormously helpful in following DRY and saving me from scaffold bloat, as Dan says.> http://dereksivers.com/rails-shared-controller.htmlOn Sep 18, 2005, at 9:02 PM, Dan Sketcher wrote:> Ages ago there was a post on this list by Derek from CD Baby (20 July > - "shared controllers in Rails") and he posted this: > http://dereksivers.com/rails-shared-controller.html which I found to > be useful as a starting point for shared infrastructure. I only use it > for the relatively simple stuff but it has really saved me from a lot > of bloat from scaffold. > > HTH, > Dan > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >