Rails未定义方法user_signed_in?

时间:2013-08-28 03:03:29

标签: ruby-on-rails ruby ruby-on-rails-3 heroku devise

一直在努力让我的网站上Heroku,并意识到我没有将//= require_tree .添加到我的application.js文件中,我相信这就是为什么我的JS文件没有加载。

添加之后,我在生产模式下推送到Heroku并获得错误“undefined method'user_signed_in?'对于#<#:0x00000003fd2d18>“

我已尝试将我的观看中对user_signed_in?的所有引用更改为signed_in?(:user),但这没有任何区别。我正在运行Rails 3.2.13,这就是我在Gemfile中获取Devise gem的方法:

gem "devise", :git => "git://github.com/plataformatec/devise.git"

有什么建议吗?

更新 - Routes.rb

BrainDb::Application.routes.draw do

devise_for :users

resources :submissions
get "/submissions/new(.:format)" => "submissions#new"
get "/submissions/:id(.:format)" => "submissions#show"
post "/submissions/:id(.:format)" => "submissions#update"

resources :folders

root to: 'home#index'

scope "api" do
get "/submissions(.:format)" => "submissions#index"
get "/submissions/:id(.:format)" => "submissions#show"
get "/:user_id/submissions(.:format)" => "submissions#usercontent"
get "/:user_id/submissions/:id(.:format)" => "submissions#usersubmission"



get "/:user_id/folders(.:format)" => "folders#userfolders"

get "/submissions/:id/edit(.:format)" => "submissions#edit"

get "/folders/new(.:format)" => "folders#new"

end

的application.js:

//= require jquery
//= require jquery_ujs
//= require_tree .

我使用它的Application.html.erb:

<% if user_signed_in? %>

<div id="fixed_nav">
<h3 id="logo"><a href="/">chakra</a></h3>
<%= form_tag(folders_path, :method => "get", class: "navbar-form", id: "search-form") do %>
    <div class="input-append">
        <%= text_field_tag :search, params[:search], placeholder: "Search for anything", :class => "form-field" %>
        <button class="btn btn-edit" type="submit form-submit"><i class="icon-search"></i></button>
    </div>
<% end %>
<div id="settings-links">
    <%= link_to "Settings", edit_user_registration_path, :method => :get %>
    <%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
</div>
</div>

<% else %>

<div id="fixed_nav">
<h3><a href="/">chakra</a></h3>
</div>

<% end %>

User.rb:

class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :user_id, :submissions, :folders
# attr_accessible :title, :body

has_many :submissions
has_many :folders

end

1 个答案:

答案 0 :(得分:0)

有时,ApplicationController中的方法'clear_helpers'阻止Devise加载他的助手。

删除此方法应该是您的绿灯。

config.action_controller.include_all_helpers = false
你的application.rb

中的