Rails on the Run

Rails experiments by Matt Aimonetti

Browsing Posts tagged utf8

I’m quite glad to let you know that my first patch made it to Rails Edge.

UPDATE: Ryan Daigle covered the new added features in his blog
How cool is that?

That’s a great achievement that I owe to josh Knowles and Josh Susser

Josh Knowles and Matt Heidemann from Integrum started working on rake_tasks a little while ago. I helped them hacking this cool plugin. After a while, we realized that the plugin was getting too big and we decided to split it in two:

  • db_tasks
  • svn_tasks

Without telling the other guys (sorry!), I started discussing merging some of the rake_tasks plugin in Rails core.

I then submitted my patch following Josh Susser recommendations.

Today, Josh congratulated me on the merge. I’m quite glad/proud that our work made it to Edge.

What’s that patch anyway?

Here are the 2 features my patch added to the future Rails 2.0:

  • MySQL: create_database takes :charset and :collation options. Charset defaults to utf8.
  • Add db:create, drop, reset, charset, and collation tasks

That means that you cna now do that:

$rails my_app
$rake db:create
$ruby script/server

That’s it, you have a working Rails app!! Well, almost, there’s nothing it in yet but at least your databases are created. Ohh, and your database is unicode, that also means that all your new tables will be utf8.

Enjoy :)

Josh knowles and Matt Heidemann from Integrum and I released few weeks a go a cool plugin called rake_tasks

The thing is that the plugin was getting too big when I started hacking the MySQL adapter and adding utf-8 support we figured out it was smarter to split the plugin and create dbtasks and svntasks

I temporarily hosted db_tasks there:

http://svn.aimonetti.net/public/plugins/db_tasks/

ruby script/plugin install http://svn.aimonetti.net/public/plugins/db_tasks/

check your Rake tasks:

  • rake db:create Creates the databases defined in your config/database.yml (unless they already exist) You can also specify the charset and collation you want your dbs to use: rake db:create CHARSET=’latin1′ COLLATION=’latin1_bin’)
  • rake db:drop Drops the database for your currenet RAILS_ENV as defined in config/database.yml
  • rake db:reset Drops, creates and then migrates the database for your current RAILS_ENV
  • rake db:shell Launches the database shell using the values defined in config/database.yml
  • rake db:charset Returns the charset of your current RAILS_ENV database
  • rake db:collation Returns the collation of your current RAILS_ENV database
  • rake db:update_connection_settings add the encoding format to each environment in the database.yml file

By default, your new databases will be utf8, you can automatically create your databases by typing:

rake db:create

or reset your databases (drop, create, migrate)

rake db:reset

Another simple plugin for lazy developers.