Created
October 25, 2013 13:48
-
-
Save the8472/7154979 to your computer and use it in GitHub Desktop.
squeel + globalize breakage
This file contains 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
#!/usr/bin/env ruby | |
gem 'activerecord', "~> 3.2.0" | |
gem "squeel" | |
gem "globalize", "~> 3.0.0" | |
gem 'sqlite3' | |
require "active_record" | |
require "squeel" | |
#require "globalize" | |
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:" | |
m = ActiveRecord::Migration.new | |
m.verbose = false | |
m.create_table :as do |t| | |
t.timestamps | |
end | |
m.create_table :bs do |t| | |
t.integer :poly_id | |
t.string :poly_type | |
t.string :title | |
end | |
class A < ActiveRecord::Base | |
has_one :poly_one, :class_name => "B", :as => :poly, :conditions => {:title => "x"} | |
end | |
class B < ActiveRecord::Base | |
belongs_to :poly, :polymorphic => true | |
end | |
a = A.create! | |
b = a.create_poly_one! | |
puts b.title == "x" ? "success" : "fail" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment