2012-07-10 146 views
0

我正在使用Enki gem創建博客應用程序。默認情況下,它使根路線posts_controller.rb的指數更改根路線的導軌

root :to => 'posts#index' 

不過,我不希望博客成爲根頁,所以,我做了一個homes_controller.rb支架和試圖將其設置爲根

root :to => 'homes#index' 

然而,儘管做出這樣的轉變中,它仍然解決的職位#索引時我啓動服務器。即使我嘗試使用新的瀏覽器也是如此(即它不是緩存問題)。

我已經複製下面的config/routes.rb文件。任何人都可以解釋...

Enki::Application.routes.draw do 


    namespace :admin do 
    resource :session 

    resources :posts, :pages do 
     post 'preview', :on => :collection 
    end 
    resources :comments 
    resources :undo_items do 
     post 'undo', :on => :member 
    end 

    match 'health(/:action)' => 'health', :action => 'index', :as => :health 

    root :to => 'dashboard#show' 
    end 

    resources :archives, :only => [:index] 
    resources :pages, :only => [:show] 
resources :homes 
    constraints :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/ do 
    get ':year/:month/:day/:slug/comments' => 'comments#index' 
    post ':year/:month/:day/:slug/comments' => 'comments#create' 
    get ':year/:month/:day/:slug/comments/new' => 'comments#new' 
    get ':year/:month/:day/:slug' => 'posts#show' 
    end 

    scope :to => 'posts#index' do 
    get 'posts.:format', :as => :formatted_posts 
    get '(:tag)', :as => :posts 
    end 

    #root :to => 'posts#index' 
    root :to => 'homes#index' 

end 
+2

嘗試將根路由移動到文件頂部 – Dty 2012-07-10 05:55:28

回答

0

把根放在路由文件的頂部。 Rails路由自上而下解決