Created
March 29, 2012 16:14
-
-
Save bill-transue/2239154 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Cable < ActiveRecord::Base | |
| has_many :connections, :class_name => 'Port', :autosave => false | |
| end |
This file contains hidden or 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 Port < ActiveRecord::Base | |
| belongs_to :cable, :dependent => :destroy | |
| has_many :connections, :through => :cable, :conditions => 'ports.id != #{self.id}' | |
| end | |
| #>> Port.last.connections.empty? | |
| #ActiveRecord::StatementInvalid: Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right | |
| #syntax to use near ') AND ((ports.id != 1768)))' at line 1: SELECT count(*) AS count_all FROM `ports` INNER JOIN `cables` ON `ports`.cable_id = `cables`.id | |
| #WHERE ((`cables`.id = ) AND ((ports.id != 1768))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment