一直在努力让我的网站在 Heroku 上运行,并意识到我没有添加//= require_tree .
到我的 application.js 文件中,我相信这就是我的 JS 文件没有被加载的原因。
添加后,我以生产模式推送到 Heroku 并收到错误“未定义的方法 '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
应用程序.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 %>
用户.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