Created
November 26, 2013 13:53
-
-
Save tagrudev/7658574 to your computer and use it in GitHub Desktop.
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
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> |
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
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