Rails, Firefox, Anime, Mac – Still working on the blog theme!
In: Edge Rails| General
11 May 2008This week’s report covers changes from 5th May 2008 to 11th May 2008 (the day the corresponding Rails Envy podcast was recorded).
A script/dbconsole script has been added that allows you to connect to your database using its console client.
If you needed to connect to your production MySQL database (you better know what you are doing!), for example, you can run RAILS_ENV=production script/dbconsole or simply script/dbconsole production (thanks to Ryan Bates for pointing this out!) and it will login to your database server using the command line MySQL client. This also works with the PostgreSQL and SQLite databases.
To use this script in your Rails app, remember to run rake rails:update:scripts after updating to edge Rails.
This nice little enhancement courtesy of Steve Purcell, who originally had a similar database console plugin.
Related changeset: http://github.com/rails/rails/commit/4a07103687084496b773e18a03b1f2f5e686f7ad
This is something that many of us Rails developers have probably come across when writing tests for flash messages being set with flash.now, myself included. Basically, you couldn’t test the contents of your flash.now because they were always being emptied before your test could get to them.
# In your controller:
flash.now[:notice] = 'You gotta be kidding me!'
# In your test:
assert_equal 'You gotta be kidding me!', flash.now[:notice]
# FAILS because flash.now[:notice] is nil
Andreas Neuhaus took a good look at how it works and figured out how to make testing flash.now work without resorting to assert_selects.
Related changeset: http://github.com/rails/rails/commit/74eed6290e63111d1aad2b181692a84f4f040aea
There isn’t much else of note so far but if you’d like to know every gritty detail, you’d probably want to peruse the Rails commit logs. As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque sed felis. Aliquam sit amet felis. Mauris semper, velit semper laoreet dictum, quam diam dictum urna, nec placerat elit nisl in quam. Etiam augue pede, molestie eget, rhoncus at, convallis ut, eros. Aliquam pharetra.
4 Responses to Living on the edge (of Rails) #20 – script/dbconsole and flash.now now test-able
Juan Lupión
May 12th, 2008 at 3pm
Hi, just a note to let you know that I’m translating your “Living on the edge … ” series into spanish in my blog.
A Fresh Cup » Blog Archive » Double Shot #205
May 12th, 2008 at 7pm
[...] Living on the Edge (of Rails) #20 – Things are moving slowly in edge Rails at the moment. [...]
Ryan Bates
May 13th, 2008 at 1am
It appears that dbconsole allows you to pass the environment as the first argument. So you can do this instead of setting RAILS_ENV.
script/dbconsole production
Also, if you want to do this make sure your database.yml settings are correct for that environment so it knows how to connect.
Chu Yeow
May 18th, 2008 at 8pm
Thanks for pointing that out Ryan! I’ve amended my post.