【问题标题】:Action Controller: Exception caught - turbolinks issue?动作控制器:捕获异常 - turbolinks 问题?
【发布时间】:2013-07-22 07:21:40
【问题描述】:

我正在关注 Michael Hartl 的 Rails 指南,当我加载 localhost:3000 时,我在浏览器中收到以下错误消息:

 Sprockets::FileNotFound in Static_pages#home

 Showing /home/jonathan/Desktop/railsTut/sample_app/app/views/layouts/application.html.erb   where line #6 raised:

couldn't find file 'turbolinks'
 (in /home/jonathan/Desktop/railsTut/sample_app/app/assets/javascripts/application.js:16)

这是来自上述消息的我的文件

// This is a manifest file that'll be compiled into application.js, which will include     all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts,      vendor/assets/javascripts,
 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a     relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the    bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE     SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree .

另外,我不确定它是否相关,但这是我的 Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.13'
gem 'bootstrap-sass', '2.1'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'jquery-rails', '2.0.2'

   group :development, :test do
    gem 'sqlite3', '1.3.5'
 gem 'rspec-rails', '2.11.0'
 # gem 'guard-rspec', '1.2.1'
 # gem 'guard-spork', '1.2.0'
 # gem 'childprocess', '0.3.6'
 # gem 'spork', '0.9.2'
   end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.5'
  gem 'coffee-rails', '3.2.2'
  gem 'uglifier', '1.2.3'
end

group :development do
  gem 'annotate', '2.5.0'
end

group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '4.2.1'
gem 'cucumber-rails', '1.2.1', :require => false
gem 'database_cleaner', '0.7.0'
# gem 'launchy', '2.1.0'
# gem 'rb-fsevent', '0.9.1', :require => false
# gem 'growl', '1.0.3'
end

group :production do
  gem 'pg', '0.12.2'
end

非常感谢任何帮助!

【问题讨论】:

  • 没关系,我只需要将 gem 'turbolinks' 添加到 Gemfile :)

标签: ruby-on-rails railstutorial.org


【解决方案1】:

如我所见,您的 gemfile 中没有“turbolinks”......只需添加它! :

  • gem 'turbolinks' 添加到您的 Gemfile。
  • 运行bundle install
  • //= require turbolinks 添加到您的 Javascript 清单文件(通常 发现于app/assets/javascripts/application.js)。
  • 重新启动您的 服务器,而您现在正在使用 turbolinks!

【讨论】:

    【解决方案2】:

    正如 RomanDev 所说,只需将其删除,除非您像我一样尝试使用 turbolink。

    在这种情况下,请从您的 application.js 文件中删除 //= require turbolinks

    【讨论】:

      【解决方案3】:

      我花了很长时间才意识到向 gemfile 添加 turbolink 可以解决这个问题。我也是初学者(显然)正在阅读 Hartl 的教程。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-16
        • 2018-02-07
        • 1970-01-01
        • 2013-03-14
        相关资源
        最近更新 更多