Created
March 5, 2013 12:30
-
-
Save blasterpal/5089998 to your computer and use it in GitHub Desktop.
Add default_scope to sort by :id for MySQL -> PostgreSQL migration, working version Rails 3.1.x
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
| # Add to initializer | |
| module SortedById | |
| extend ActiveSupport::Concern | |
| included do | |
| default_scope order('id ASC') | |
| end | |
| end | |
| Rails.application.eager_load! | |
| models = ActiveRecord::Base.subclasses.collect {|ea| ea.name} | |
| models.each do |mod| | |
| Module.class_eval(mod).send(:include,SortedById) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Was there a reason you didn't declare the default_scope on ActiveRecord::Base ?