2015-02-05 60 views
0

我有以下的在我的routes.rb:will_paginate混亂網址色器件驗證的根路徑

... 
authenticated :user do 
    root to: 'game_shelves#index', as: :authenticated_root 
end 
unauthenticated do 
    root to: 'editions#index' 
end 
... 
resources :editions, :path => "games" do 
    collection do 
     get 'to_review' 
     post 'review' 
     get 'existing_work' 
    end 
    member do 
     put 'split' 
    end 
    resources :expansions do 
    end 
end 
... 

will_paginate是這樣的:

<%= will_paginate @collection, renderer: BootstrapPagination::Rails %> 

而結果鏈接是這樣的:

http://localhost:3000/?page=2

如果我讓未經驗證的根比版本#指數另一件事,鏈接是正確的,就像這樣:

<%= will_paginate @collection, :params => {:controller => '/editions', :action => 'index'}, renderer: BootstrapPagination::Rails %> 

http://localhost:3000/games?page=2

我已經使用這個嘗試

但它不強制will_paginate使用正確的路線。如果我試試這個:

<%= will_paginate @collection, :params => {:controller => editions_path }, renderer: BootstrapPagination::Rails %> 

Rails的給我的路線錯誤:

沒有路由匹配{:動作=> 「指數」:控制器=> 「遊戲」,:頁=> 2 }

回答

0

我倒了我的routes.rb,它現在可以工作。看起來秩序很重要,我不知道。

... 
resources :editions, :path => "games" do 
    collection do 
     get 'to_review' 
     post 'review' 
     get 'existing_work' 
    end 
    member do 
     put 'split' 
    end 
    resources :expansions do 
    end 
end 
authenticated :user do 
    root to: 'game_shelves#index', as: :authenticated_root 
end 
unauthenticated do 
    root to: 'editions#index' 
end