Skip to content

Instantly share code, notes, and snippets.

@the8472
Created October 25, 2013 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the8472/7154979 to your computer and use it in GitHub Desktop.
Save the8472/7154979 to your computer and use it in GitHub Desktop.
squeel + globalize breakage
#!/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