Accessing database model from generator?

i’m writing my own generator :slight_smile: basically a custom scaffolding type
thing to make my life easier when creating new resources.

instead of doing something like script/generate custom_scaffold
MyResource name:string description:string … i decided to store all
the metadata about the tables and fields in the db.

my generator creates the model stub files when given a name that
corresponds to a table that already exists and which has metadata in
the database. i would like to check in my generator code if metadata
exists for the table in the DB before going ahead and creating all the
views, model, controller, etc…

i’m not sure if this is kosher rails coding to have a generator that
depends on the existence of specifc models/tables to work… but this
is just for me and i will make sure they are there whenever i use it…

any ideas?

another question… i have a “m.route_resources file_name.pluralize”
line in my generator manifest… is there anyway i can easily check if
the route already exists? if i run my generator multiple times (which
is gonna happen a lot since its still in the works) it keeps adding
duplicate routes in my routes.rb.

Thanks!! happy coding everyone :slight_smile:

Stuart

looks like i have a knack for asking dumb questions… you can just go
ahead and use the models :stuck_out_tongue:

anybody got a handle on how to check if a resource route already
exists in routes.rb?

Stuart