On Apr 19, 9:59 pm, John Merlino <li...@ruby-forum.com> wrote: > Hey all, > > This right here: > > scope :index_blog, { > :select => "blog_posts.*", > :joins => "INNER JOIN categories ON category.id = > blog_posts.category_id", > :conditions =>"blog_posts.enabled = 1" > } > > returns this: > > Mysql2::Error: Not unique table/alias: 'categories': SELECT blog_posts.* > FROM `categories` INNER JOIN categories ON category.id = > blog_posts.category_id WHERE (blog_posts.enabled = 1) > > But I am not trying to select blog_posts.* from categories. I am trying > to select blog_posts.* from blog_posts. However, because I do this > within the category model, it fills in categories. And I don't know how > to select from blog posts from category model. I'm also curious if there > is a better way to do this? >
Why are you trying to define a scope on blog posts in the categories model? Even if you fix the query, rails will still try and create instances of Category rather than instances of BlogPost Fred > Thanks for response. > > -- > Posted viahttp://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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.