ActionController :: Routing :: Routes.draw做什么|映射|做?

时间:2014-09-08 13:33:48

标签: ruby-on-rails ruby routing

我在路线文件中有以下代码,我之前没有遇到过,但需要了解它但我不知道发生了什么,因为我和#39; ve只使用了match ...

ActionController::Routing::Routes.draw do |map|
  map.devise_for :users, :controllers => { :confirmations => 'confirmations' }
  map.resources :sections, :only => [:index, :show]

  def stories(parent)
    parent.resources :stories, :only => [:index, :show], :collection => {:search => :get} do |story|
      story.resources :videos, :only => [:index], :member => {:play => :get, :start_download => :get}
      story.resources :images, :only => [:index], :member => {:start_download => :get}
      story.resources :documents, :only => [:index], :member => {:start_download => :get}
      story.resources :audios, :only => [:index], :member => {:play => :get, :start_download => :get}
    end
  end

  stories(map)

  map.namespace :manage do |client_admin|
    client_admin.resources :stories do |story|
      story.resources :meta_datas
      story.resources :media_files, :collection => { :clone_metadata => :get }, :member => { :crop_thumbnail => :get } do |mf|
        mf.resources :media_meta_datas
      end
    end
    client_admin.resources :users, :only => [:new, :create, :index]
  end

  map.ftp_upload 'manage/stories/:story_id/ftp', :controller => 'manage/media_files', :action => 'ftp'

  map.page ':page', :controller => 'pages', :action => 'show', :page => /terms/
  map.contact '/contact', :controller => 'contact', :action => 'index'
  map.resource :password_reminder

  map.library_redirect '/library', :controller => 'media_files', :action => 'redirect'
  map.library '/library/:media_type', :controller => 'media_files', :action => 'index'

  map.press_kits '/corporate-information', :controller => 'stories', :action => 'press_kits'

  map.resource :global_toolkit, :controller => 'global_toolkit', :as => 'global-toolkit', :only => 'show' do |toolkit|
    toolkit.library_redirect '/library', :controller => 'global_toolkit_media_files', :action => 'redirect'
    toolkit.library '/library/:media_type', :controller => 'global_toolkit_media_files', :action => 'index'
    toolkit.press_materials '/press-materials', :controller => 'stories', :action => 'press_materials'
    toolkit.brand_guidelines '/brand-guidelines', :controller => 'stories', :action => 'brand_guidelines'
    toolkit.martini_contacts '/martini-contacts', :controller => 'stories', :action => 'martini_contacts'

    stories(toolkit)
  end

  map.root :sections
end

当我转到网址/global-toolkit/brand-guidelines1时,它会显示unknown action,但据我所知,它应该有效。

0 个答案:

没有答案