0

I'm using the Enki gem to create a blogging application. By default, it makes the root route to the index of the posts_controller.rb

root :to => 'posts#index'

However, I don't want the blog to be the root page, so, I made a scaffold with a homes_controller.rb and tried to set it to the root

root :to => 'homes#index'

However, in spite of making that change, it's still resolving to posts#index when I start the server. It does the same even if I try in a new browser (i.e. it's not a caching issue).

I have copied the config/routes.rb file below. Can anyone explain...

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
4

1 回答 1

0

将根放在路由文件的顶部。Rails 路由自上而下解析

于 2012-07-10T17:56:34.690 回答