Thank God for Lighthouse.
I got this error (private method `split' called for :id:Symbol, in my case) because my has_many statement had :order => :id specified (yes, it looks a trivial order; it's legacy code, so give me a break).
Aha! We shouldn't be using symbols to represent table columns in our has_many statements. We're really talking about an SQL fragment, anyway, so it seems more sensible to use a string anyway. Consider a case where you want to include another table:
class Organization < ActiveRecord::Base has_many :users, :order => "accounts.number", :include => :account end
class User < ActiveRecord::Base belongs_to :organization belongs_to :account end
class Account < ActiveRecord::Base has_one :user end
Certainly there's no way to do :accounts.number or something like that, and it doesn't make sense anyway. Long story short, it's OK to use Symbols for table names, but leave the columns to the strings, please!





Post a Comment