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