Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11433 (new enhancement)

Opened 3 months ago

Last modified 3 months ago

[PATCH] Adds script/console for Rails Contributors (for the activerecord test models)

Reported by: thechrisoshow Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords:
Cc:

Description

This patch helps rails contributors do their job better by adding script/console for active_record associations. This allows you to examine the Rails test data just like you would any normal rails application

Use it with (from the /activerecord/ directory):

   script/console

If you want to try it with different database connector pass the adapter name as a parameter. For example:

script/console sqlite3

Attachments

add_script_console_for_rails_contributors.diff (1.8 kB) - added by thechrisoshow on 03/26/08 22:51:17.
Adds script/console for rails contributors

Change History

03/26/08 22:51:17 changed by thechrisoshow

  • attachment add_script_console_for_rails_contributors.diff added.

Adds script/console for rails contributors

03/27/08 09:24:59 changed by h-lame

This seems like an interesting idea. For example when you are writing new tests and want to go and explore the fixture "universe" in an interactive shell to find out what associations and such like are present.

However, I do have an issue with naming it script/console. I think naming it script/console brings a load of expected baggage over from the script/console we get in a rails app, and when/if this script/console doesn't deliver it violates the principle of least surprise. For example, if there's script/console for AR then it would imply to the non-investigative that there's a script/server or script/<whatever-that-comes-with-a-rails-app>, clearly a script/console makes some sense, but the others don't. Another example is that script/console in a rails app does lots of require magic and loads other libraries that this script/console doesn't do; I've not tested this script/console so I could be wrong here, but I'm pretty sure the boot.rb and environment.rb loaded by a real script/console do a lot more than this little script.

I wonder, if we could make this a rake task instead?

rake console

or

rake console_<adaptor_name>

There might be some merit in flags to allow / disallow forcing a clean load of the fixtures too.