简体   繁体   中英

Rails3 subdomain routing

I am trying to port over my Rails 2.3.5 app to Rails 3, and having trouble with the following route configurations:

 ActionController::Routing::Routes.draw do |map| 
     map.app  '', :controller => 'projects', :action => 'index', :conditions => {:subdomain => true}

      map.with_options :controller  => 'site', :action => 'page', :subdomain => false, :conditions => {:subdomain => false} do |site|
        site.site             '',        :path => 'index'
        site.pricing          'pricing', :path => 'pricing'
        site.tour             'tour',    :path => 'tour'
        site.about            'about',   :path => 'about'    
        site.contact          'contact', :path => 'contact'
        site.privacy          'privacy', :path => 'privacy'    
        site.terms            'terms',   :path => 'terms'
      end
    end

The rails 2.3.5 app is using subdomain-fu for the subdomain condition... how do I do this with Rails 3? I want to have 2 blank routes. If a subdomain is present, it routes to the app, if there is no subdomain, it should route to the site.

只需详细了解一下有关子域问题的railscast

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM