Created
November 30, 2011 13:35
-
-
Save WaYdotNET/1409071 to your computer and use it in GitHub Desktop.
Migrate All Of Your Model Classes When Using MiniRecord with Padrino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # /rake/minirecord.rake | |
| namespace :mini_record do | |
| desc "Auto migration of database" | |
| task :migrate => :environment do | |
| Dir["models/*.rb"].each do |file_path| | |
| basename = File.basename(file_path, File.extname(file_path)) | |
| clazz = basename.camelize.constantize | |
| clazz.auto_upgrade! if clazz.ancestors.include?(ActiveRecord::Base) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Been using this rake task for a project of mine and it started to fall over when I have model classes that are not ActiveRecord classes (such as the cancan ability class - which the generator for cancan places in app/models). So here is the update with a nice fix.