Skip to content

Instantly share code, notes, and snippets.

@mickeb
Created August 17, 2012 12:25
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 mickeb/3378438 to your computer and use it in GitHub Desktop.
Save mickeb/3378438 to your computer and use it in GitHub Desktop.
Squeel bug report
#encoding: utf-8
gem 'rails', '3.2.8'
gem 'squeel', '1.0.9'
require 'active_record'
require 'squeel'
require 'squeel/version'
puts "Active Record #{ActiveRecord::VERSION::STRING}"
puts "Squeel #{Squeel::VERSION}"
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => ':memory:'
)
ActiveRecord::Schema.define do
create_table :agents, :force => true do |t|
end
create_table :products, :force => true do |t|
t.belongs_to :agent
t.timestamps
end
end
class Agent < ActiveRecord::Base
has_many :products
end
class Product < ActiveRecord::Base
belongs_to :agent
scope :today, lambda {
where{ date(created_at) == Date.today }
}
end
agent = Agent.create()
product = Product.create(:agent => agent)
puts agent.products.today.to_sql # Exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment