Rails: Migrations: AddSWIFTCodes Workaround 0

Posted by yrashk

If I’m not missing something, there is a minor bug in Rails (and in Edge Rails, too) that does not allow you to specify migrations files like add_swift_codes.rb with AddSWIFTCodes class inside; it will raise an error.

dev.rubyonrails.org seems to run of out of hard drive capacity, so here you are a very quick workaround:

1
2
3
4
5
6
7
8
9
class ActiveRecord::Migrator
        def migration_class(migration_name)
                begin
                        migration_name.camelize.constantize
                rescue
                        Object.constants.grep(Regexp.new(migration_name.camelize,"i")).first.constantize
                end
        end
end

I’m not sure it is a best solution, but it seems that it works for me right now. I’ll try to write down a patch for Edge Rails + test soon.

Comments

Leave a response

Comment