MailingList


Re: Problems with setup Globalize and Postgresql database

by Gunnar Wolf :: Rate this Message:

Reply to Author | View in Thread

(Yes, I know this is an old post - but it is still an open issue, this might be useful for somebody...)

There are two ways to fix this - One is to patch Rails. I just sent a bug report, and I'd expect it to be fixed as part of the next Rails release, as it is quite straightforward:

http://dev.rubyonrails.org/ticket/11282

So, this would be the _proper_ way to fix it ;-) Now, you probably want a workaround. Very easy: After generating your 'globalize' migration, edit the generated file (say, db/migrate/009_globalize_migration.rb). Search for the following block:

      reader.each do |row|
        next if row.first.nil? # skip blank lines
        raise "No table name defined" if !table_name
        raise "No header defined" if !column_clause
        values_clause = row.map {|v| cnx.quote(v).gsub('\\n', "\n").gsub('\\r', "\r") }.join(', ')
        sql = "INSERT INTO #{table_name} (#{column_clause}) VALUES (#{values_clause})"
        cnx.insert(sql)
      end
    end

Where it is? Depends on the type of migration you requested - for the 'tiny' migration, it's at line 78. Replace cnx.insert(sql) with cnx.execute(sql) - And that's it, the migration now works.

 « Return to Thread: Problems with setup Globalize and Postgresql database