Custom Subdomains in Sinatra app
I want my Sinatra app to allow users to create an account and access it via a subdomain (i.e. your-account.myapp.com).
开发者_JAVA技巧I found this to extract subdomains (http://gist.github.com/55784#file_subdomains.rb) but I'm having a hard time implementing it.
Any ideas?
I have an Account model (datamapper) with a field called account name, which should be the subdomain.
Thanks!
Sinara uses Rack to interact with the webserver.
You could put a Rack middleware before all requests to extract the subdomain, store it on a local variable and use it wherever you need load that user.
I've found 2 resources that could help you: https://github.com/fnando/sinatra-subdomain
and
http://tannerburson.com/2009/01/extracting-subdomains-in-sinatra.html
Regards!
精彩评论