right, I was talking about the MysqlAdapter, the other database
adapters don't let you create a database.

Here is the create_database method:

      def create_database(name) #:nodoc:
        execute "CREATE DATABASE `#{name}`"
      end

Here is my suggestion:

      # Create a new MySQL database allowing you to specify the
charset and collation, by default the database is created with utf8
charset and utf8_bin collation
      # usage:
ActiveRecord::Base.connection.create_database('charset_plugin_test',
{:charset => 'latin1', :collation => 'latin1_bin'})
      def create_database(name, options = {})
        execute "CREATE DATABASE `#{name}` DEFAULT CHARACTER SET
`#{options[:charset] ||= 'utf8'}` COLLATE `#{options[:collation] ||=
'utf8_bin'}`"
      end


Nothing fancy but using utf8 by default means that people have to/
should update their database.yml file to add the encoding to each
environment.


Does it make sense?

-Matt


On May 21, 8:47 pm, DHH <[EMAIL PROTECTED]> wrote:
> > If you use ActiveRecord::Base.connection.create_database you'll notice
> > that by default the created db will use latin1 encoding. I created a
> > plugin to handle different charset and collations (on top of helping
> > you with other boring DB tasks).
>
> Which database are you talking about specifically? I believe Rails
> will use whatever the current default is. MySQL, for example, has a
> installation-wide configuration file that controls that.


--~--~---------~--~----~------------~-------~--~----~
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