I've got a model for sites that looks like:
class Site < ActiveRecord::Base
has_one :resource_1
has_one :resource_2
has_one :resource_3
has_many :resource_4
end
I've got subdomains set up following the method outlined in http://asciicasts.com/episodes/221-subdomains-in-rails-3. So that if I visit http://subdomain.myapp.com it finds the开发者_StackOverflow site by name (assuming subdomain is the site's name) and displays the page normally at /sites/:id/resource_1.
I can still access all the other sub-resources of site from there, but I get a url that looks like http://subdomain.myapp.com/sites/:id/resource_name/:resource_id and I'd like to be able to set up routes that look like http://subdomain.myapp.com/resource_name/:resource_id.
I'm sure the proper terminology is just escaping it, but not really having the language to describe it concisely has made googling for a solution unfruitful. Any and all replies are appreciated!
Thanks!
Added a method to the application controller to get site by subdomain, then used shallow routing requiring site to be present.
精彩评论