Skip to content

Instantly share code, notes, and snippets.

@tagrudev
Created November 26, 2013 13:53
Show Gist options
  • Save tagrudev/7658574 to your computer and use it in GitHub Desktop.
Save tagrudev/7658574 to your computer and use it in GitHub Desktop.
class Log < ActiveRecord::Base
self.table_name = "versions"
has_one :previous_log, :class_name => "Log",
:order => "created_at DESC",
:conditions => proc{ "item_type = #{self.item_type}" }
end
=> NoMethodError: undefined method `item_type' for #<Class:0x7f9f5200c5f0>
class Log < ActiveRecord::Base
self.table_name = "versions"
has_one :previous_log, :class_name => "Log",
:order => "created_at DESC",
:conditions => ['item_type = ?', '#{self.item_type}']
end
=> "SELECT `versions`.* FROM `versions` WHERE `versions`.`log_id` = 1 AND (item_type = '#{self.item_type}') ORDER BY created_at DESC LIMIT 1"
which also fails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment