> Yup. Another common practice is db/dataload.rb, a script of
> ActiveRecord operations to put some data into the database, with the
> corresponding db:dataload Rake task. Using AR and domain to create
> this data is much easier than doing the same thing with YAML-based
> fixtures.

I've set up apps to detect when they have an empty database, and to
run an action which uses regular AR stuff like User.new to seed the
database. That way, the application "sets itself up" the first time
it's run - no additional rake task needed (but with the overhead of
checking to see if we've got a "clean slate").

In an ideal world, I think Rails applications that have the right info
in config/database.yml would be able to create their own database
(something like rake db:create), load their own schema (rake
db:schema:load), and seed their own data (rake db:bootstrap)
automatically when run for the "first time".

The trick would be knowing when an application was being run for the
first time, but that might be as simple as telling people to not run
rake db:schema:load (or rake:db:create) and simply starting their
application after filling out config/database.yml (if database doesn't
exist or has no tables, run some "init" action if it exists).

I'm not sure if this sort of thing is possible (or a good idea), but
it might be worth thinking about.

- Trevor
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to