Skip to content

Instantly share code, notes, and snippets.

@oleander
Created April 30, 2010 18:25
Show Gist options
  • Save oleander/385584 to your computer and use it in GitHub Desktop.
Save oleander/385584 to your computer and use it in GitHub Desktop.
?> Gig.includes({:channel, :songs}).where(:channels =>{:name => "Channel", :songs => {:title => "Music"}}).order(:time)
ActiveRecord::StatementInvalid: Mysql::Error: Column 'time' in order clause is ambiguous: SELECT `gigs`.`id` AS t0_r0, `gigs`.`raw_id` AS t0_r1, `gigs`.`song_id` AS t0_r2, `gigs`.`channel_id` AS t0_r3, `gigs`.`time` AS t0_r4, `channels`.`id` AS t1_r0, `channels`.`name` AS t1_r1, `channels`.`alias` AS t1_r2, `channels`.`link` AS t1_r3, `channels`.`active` AS t1_r4, `songs`.`id` AS t2_r0, `songs`.`artist_id` AS t2_r1, `songs`.`title` AS t2_r2, `songs`.`grade` AS t2_r3, `songs`.`length` AS t2_r4 FROM `gigs` LEFT OUTER JOIN `channels` ON `channels`.`id` = `gigs`.`channel_id` LEFT OUTER JOIN `gigs` `songs_channels_join` ON `channels`.`id` = `songs_channels_join`.`channel_id` LEFT OUTER JOIN `songs` ON `songs`.`id` = `songs_channels_join`.`song_id` WHERE (`songs`.`title` = 'Music') AND (`channels`.`name` = 'Channel') ORDER BY time
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract_adapter.rb:208:in `log'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/mysql_adapter.rb:328:in `execute'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/mysql_adapter.rb:645:in `select'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/base.rb:431:in `find_by_sql'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/relation.rb:64:in `to_a'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/relation/finder_methods.rb:181:in `find_with_associations'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/relation.rb:64:in `to_a'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/relation.rb:324:in `inspect'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:302:in `output_value'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:151:in `eval_input'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:263:in `signal_status'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:147:in `eval_input'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:146:in `eval_input'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:70:in `start'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:69:in `catch'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:69:in `start'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta3/lib/rails/commands/console.rb:47:in `start'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta3/lib/rails/commands/console.rb:8:in `start'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.0.beta3/lib/rails/commands.rb:34
from script/rails:9:in `require'
from script/rails:9>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment