0
Running Rails 3. 在用户的模型文件中包含“include Rails.application.routes.url_helpers”。仍然收到此错误。任何想法??ruby rails - 未定义的局部变量或方法`new_user_session_path'
# cat app/models/user.rb
class User < ActiveRecord::Base
include Rails.application.routes.url_helpers
acts_as_authentic
end
# rake routes
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
root / users#index
# cat config/routes.rb | grep -v '#'
www::Application.routes.draw do
resources :users
end
错误 -
Showing /var/www/app/views/users/index.html.erb where line #7 raised:
undefined local variable or method `new_user_session_path' for #<#<Class:0x9a51c6c>:0x9bb6170>
Extracted source (around line #7):
4:
5: <p>Public Facing Content</p>
6:
7: <%= link_to 'Login', new_user_session_path %>
是。我正在使用authlogic,并生成了user_session类和控制器 – 2012-03-24 09:15:07
您可以发布您的routes.rb和rake路由的输出吗? – 2012-03-24 09:41:03
'#耙路线 用户获得/users(.:format)用户#指数 POST /users(.:format)用户#创建 new_user GET /users/new(.:format)用户#新 edit_user GET /用户/:id/edit(.:format)users#edit user GET /users/:id(.:format)users#show PUT /users/:id(.:format)users#update DELETE/users /: id(。:format)users#destroy root/users#index #cat config/routes.rb | grep的-v“#” WWW :: Application.routes.draw做 资源:用户 end' – 2012-03-24 09:43:36