我试图使用自定义路线去/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