Created
January 27, 2013 16:25
-
-
Save jonleighton/4649087 to your computer and use it in GitHub Desktop.
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
| require "active_record" | |
| require "logger" | |
| puts ActiveRecord::VERSION::STRING | |
| $rails4 = ActiveRecord::VERSION::MAJOR > 3 | |
| # ActiveRecord::Base.logger = Logger.new(STDERR) | |
| ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:' | |
| ActiveRecord::Schema.define do | |
| create_table :projects | |
| create_table :tasks | |
| end | |
| class Project < ActiveRecord::Base | |
| if $rails4 | |
| has_many :tasks, -> { where foo: 'a' } | |
| else | |
| has_many :tasks, conditions: { foo: 'a' } | |
| end | |
| end | |
| class Task < ActiveRecord::Base | |
| default_scope -> { where foo: 'b' } | |
| end | |
| p = Project.create | |
| puts p.tasks.to_sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment