我試圖使用自定義路線去/admin/home
但它不斷給我的錯誤:使用= link_to 'Home', home_admins_path
我的路由有什麼問題?
當我運行rake routes
時undefined local variable or method 'home_admins_path' for #<#<Class:0x007f8272855808>:0x007f8272b9f298>
看來,路徑是有效的: home_admins_path GET /admins/home(.:format) admins#home
路線.RB
MyApp::Application.routes.draw do
devise_for :admins
get '/admins/home' => 'admins#home', as: :home_admins_path
resources :admins
root to: 'pages#home'
end
admins_controller.rb
class AdminsController < ApplicationController
load_and_authorize_resource
def home
render "admins/home.html.haml"
end
end
我希望這個答案也會有幫助http://stackoverflow.com/questions/7053754/ruby-on-rails-routes/7054021#7054021 – rubish