-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scoping not working under Rails 5 #233
Comments
Do you think you can write a spec for this? |
No, don't really know how to do that. Could the documentation just be corrected? Is there something beyond changing reference_in to belongs_to and references_many to has_many? |
Maybe. Make a pull request and we can talk about it. I didn't dig any deeper into the issue, but I can try. |
Update I had the same problem, updating to mongoid 6.0.3 solved! That is working A channel has several episodes: Channel class Channel
include Mongoid::Document
include Mongoid::Slug
field :title, type: String
slug :title
validates :title, presence: true
has_many :episodes
end Episode class Episode
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Slug
field :title, type: String
field :description, type: String
field :url, type: String
field :published_at, type: DateTime
slug :title, scope: :channel
validates :title, presence: true
validates :url, presence: true
validates :published_at, presence: true
belongs_to :channel
end |
Hi,
The docs for scoping say to use referenced_in and references_many but these options appear to have been deprecated in favour of more ActiveRecord-style belongs_to and has_many (I think--??).
Under Mongoid 6.0.2 and mongoid-slug 5.3.1 (master branch), the scope option doesn't work (at least when set up with belongs_to and has_many -- using referenced_in and references_many, as specified in the docs, throws an exception, so what am I doing wrong?
Saving a record with a duplicate slugged attribute (but a different scope) throws the dreaded 'E11000 duplicate key error index' error. I've tried explicitly defining the _id association as well, as suggested by the docs.
If scoping is still possible, could the README.md please be updated to indicate how to do this?
Thanks!
The text was updated successfully, but these errors were encountered: