Hi,
I was adding a new relationship to my database tables. Basically,
previously an application has many hosts, so the paginate statement
would be like this when I am listing hosts for abc application:
@hosts_pages, @hosts = paginate(:hosts, :include => :app, :conditions =>
“application = abc”)
model:
App
has_many :hosts, :dependent => :destroy
Host
belongs_to :app
It works fine so far.
Now, I am adding a role table and it no longer works.
@hosts_pages, @hosts = paginate(:hosts, :include => [:app, :role],
:conditions => “application = abc”)
model:
App
has_many :hosts, :dependent => :destroy
Host
belongs_to :app
has_many :host_permissions, :dependent => :destroy
has_many :role, :through => :host_permissions
Role
has_many :host_permissions, :dependent => :destroy
has_many :host, :through => :host_permissions
It would complain
Unknown column ‘application’ in ‘where clause’: SELECT id FROM hosts
WHERE (application = ‘abc’) LIMIT 0, 10
It doesn’t make any sense since adding a left outer join statement will
only add columns, not remove them. Do anyone have any suggestion what I
have done wrong?