This project is archived and is in readonly mode.
Not unique table/alias/ambiguous column name with chained named_scopes
-
Santiago Pastorino
- State changed from new to open
- Tag changed from 2.3.9, bug, joins, named_scope to 239, bug, joins, named_scope
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
-
Dan
- State changed from stale to open
[state:open]
Still an issue in Rails 3.0.4 As above run
rake db:migrate
rake db:seed
rails cLoading development environment (Rails 3.0.4)
Category.good.joins(:items) ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column name: name: SELECT "categories".* FROM "categories" INNER JOIN "items" ON "items"."category_id" = "categories"."id" WHERE (name = 'Good Stuff')
As a workaround, if you recreate the scope as follows:
scope :good, :conditions => ["categories.name = 'Good Stuff'"]then it works fine. I'm not sure what implications this would have on intersection between scopes, but in this demo
Category.good.important.joins(:items)
does work.
