【发布时间】:2013-08-21 23:22:50
【问题描述】:
我正在尝试使用自定义路由去/admin/home,但它一直给我错误:undefined local variable or method 'home_admins_path' for #<#<Class:0x007f8272855808>:0x007f8272b9f298> when using = link_to 'Home', home_admins_path
当我运行rake routes 时,路径似乎是有效的:
home_admins_path GET /admins/home(.:format) admins#home
routes.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
【问题讨论】:
标签: ruby-on-rails routes