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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Is ''application'' a column in one of your tables? Maybe you are using the wrong column name in the conditions. On 2/26/07, Wai Tsang <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > > I was adding a new relationship to my database tables. Basically, > previously an application has many hosts, so the paginate statement--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bala Paranj wrote:> Is ''application'' a column in one of your tables? Maybe you are using > the wrong column name in the conditions.Of course. Otherwise, it wouldn''t work before :p I found a workaround for this problem. It seems like if :include is used, and if more than one table is specified, the column name can only be matched if you specify the table name as well. In my case, it would be "apps.application". Maybe it is a bug in rails? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---