We have used database views to share database content between rails application, and experience problems with a many to many association. With a has_many through setup, the current query from the app using views returns:
SELECT `users`.* FROM `users` INNER JOIN `users_roles` ON `users`.`` = `users_roles`.`user_id` WHERE `users_roles`.`role_id` IS NULL
After we looked into it, it seems to us that when the database views don't have any explicit keys, it is not recognized, and it generates IS NULL instead of == 1
Can be resolved by setting set_primary_key "id"
Thanks for posting this. It solved my problem too.
I'm closing this issue, because it seems to be solved already.
If you have any problem, please comment to this issue.
BTW, I think that A View (except so-called materialized view) has no keys.