我正在使用设计来验证我的应用程序中的用户。问题是我的应用程序中不存在任何设计助手。例如。在文件app/controllers/admin/dashboard.php
中,我有这段代码:
<% if user_signed_in ? %>
do something
<% end %>
我明白了
undefined method `user_signed_in?'
这是rake routes
命令的输出
new_admin_session GET /admin/sign_in(.:format) devise/sessions#new
admin_session POST /admin/sign_in(.:format) devise/sessions#create
destroy_admin_session DELETE /admin/sign_out(.:format) devise/sessions#destroy
admin_password POST /admin/password(.:format) devise/passwords#create
new_admin_password GET /admin/password/new(.:format) devise/passwords#new
edit_admin_password GET /admin/password/edit(.:format) devise/passwords#edit
PUT /admin/password(.:format) devise/passwords#update
cancel_admin_registration GET /admin/cancel(.:format) devise/registrations#cancel
admin_registration POST /admin(.:format) devise/registrations#create
new_admin_registration GET /admin/sign_up(.:format) devise/registrations#new
edit_admin_registration GET /admin/edit(.:format) devise/registrations#edit
PUT /admin(.:format) devise/registrations#update
DELETE /admin(.:format) devise/registrations#destroy
login /admin/login(.:format) devise/sessions#new
login /admin(.:format) devise/sessions#new
admin_dashboard_index GET /admin/dashboard/index(.:format) admin/dashboard#index
这是 routes.rb 的内容
devise_for :admin
devise_scope :admin do
match 'admin/login' => 'devise/sessions#new', :as => :login
match 'admin' => 'devise/sessions#new', :as => :login
get "admin/dashboard/index"
end
namespace :admin do
resources :images
end
和管理员模型
class Admin < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me
end
这里有什么问题?我可以注册或登录,但我不能使用辅助方法。