Skip to content
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

More on models "restricted" by the subdomain #1

Open
eimermusic opened this issue Dec 6, 2011 · 0 comments
Open

More on models "restricted" by the subdomain #1

eimermusic opened this issue Dec 6, 2011 · 0 comments

Comments

@eimermusic
Copy link

I wanted to make something like a "feature request".

This app is a great example because of Mongoid and Device but only goes about as far as other tutorials on subdomains I have seen. I.E. creating a profile page based on the subdomain. What I have never seen covered is a more generally useful technique for partitioning data to subdomains. You may call it "Basecamp-style" or however you want to call it.

Basically a re-usable way to make sure that sub1.domain.com/posts only show posts created for that subdomain. (Dumb classic example, I know.)

In some apps, scoping the user and going on associations from there is enough but I think in many cases you want more.

I have run into problems trying to make Mongoid do this with any degree of Magic®. It would seem easy to use the default scope to say limit a domain field to request.subdomain. Doesn't work. Mongoid "resolves" the default scope only once and then re-uses that for every query in every request. So, after a restart, all queries would scope to the domain of the first request. (Not apparent while in development)

The reason I think subdomain constraints should be implemented sort-of like default_scope is that it becomes a configuration on the model and not something you can forget to do in some query somewhere. This feels a lot safer when the object is to avoid data bleeding between domains.

Thanks for a nice example app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant