已解决:我在 ApplicationController 中使用了“clear_helpers”方法,因此阻止了 Devise 加载他的助手。
你好,
当我第一次在“开发”模式下运行我的应用程序时,我得到这个错误,当我重新加载错误消失时。当我在“生产”上运行时,错误仍然存在,因为生产只加载应用程序一次(?),所以发生了什么?有人可以帮忙吗?
错误:
undefined method `user_signed_in?' for #<#<Class:0x10312ddc0>:0x103127100>
Extracted source (around line #16):
13:
14: #top
15: = link_to '', root_path, :id => 'logo'
16: - if user_signed_in?
17: #session
18: %p= raw "Olá <b>#{current_user.email}</b>"
19: #myaccount.button{:onclick => "javascript: document.location.href = '#{edit_user_registration_path}'"}
我使用具有以下设置的设计:
导轨:3.1,设计:1.3.4
我的模型:
class User::Account < ActiveRecord::Base
devise :database_authenticatable, :confirmable, :lockable, :recoverable,
:rememberable, :registerable, :trackable, :timeoutable, :validatable,
:token_authenticatable
end
路线:
Foco::Application.routes.draw do
devise_for :users, :class_name => 'User::Account'
root :to => 'main/cockpit#index', :constraints => lambda {|r| r.env["warden"].authenticate? }
devise_scope :user do
root :to => "devise/registrations#new"
end
end
我的控制器:
class Main::CockpitController < ApplicationController
before_filter :authenticate_user!
def index
end
end
谢谢!