未预编译application.js [英] application.js isn't precompiled

查看:110
本文介绍了未预编译application.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定为什么,但是每当我运行rake assets:precompile时,application.js都不会被编译.在生产模式下出现未预编译application.js"错误.

I'm not sure why, but whenever I run rake assets:precompile, application.js doesn't get compiled. I get a "application.js isn't precompiled" error in production mode.

如果有任何含义,这是我的Gemfile:

Here is my Gemfile if it means anything:

source 'http://rubygems.org'

gem 'rails', '3.1.1'
gem 'eventmachine', '1.0.0.beta.4.1'
gem 'thin'
gem 'mysql'
gem 'win32-open3-19'
gem 'paperclip', '2.3.8'
#gem 'jammit'
gem 'jsmin'
gem 'will_paginate'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.1.4'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
end

我制作了一个新的Rails应用并测试了rake资产:预编译,并且可以正常工作.就相关文件而言,这两个应用程序之间的唯一区别是我安装了哪些gem.两个应用程序之间的"application.js"是相同的...环境文件也是如此.

I made a new rails app and tested the rake assets:precompile and it's working. The only difference between the two apps in terms of relevant files would be what gems I have installed. "application.js" is the same between both apps...as are the environment.rb files.

还要注意...当我在我的Assets/javascripts目录中包含一个随机的.js文件并使用"javascript_include_tag:application"时,在开发人员模式下生成的其中一个URL如下所示:/assets/../javascripts/anytimec.js?body=1,它们显然失败了带有404.但是,正确引用了application.js文件.

Also of note...when I include a random .js file in my assets/javascripts directory and use "javascript_include_tag :application", one of the resulting URLs in dev mode look like so: /assets/../javascripts/anytimec.js?body=1 and they obviously fail with 404. However the application.js file is referenced correctly.

更新:

在研究链轮产生的东西时,我注意到逻辑路径"在该位置使用了"../javascripts".我通过分别查看asset_paths.asset_for('application','js')和asset_paths.asset_for('anytimec','js')的转储进行了测试.我还比较了这些转储与新应用程序中的相同文件.全新的应用程序不会将"../javascripts"放在该位置,而我当前的应用程序却不会.它不会对CSS文件或其他任何内容执行此操作……只是javascript.这绝对是在暗示核心问题,但我不知道从这里出发.

Looking into what Sprockets generates I've noticed that the "logical path" uses "../javascripts" in the location. I tested this by looking at the dump of asset_paths.asset_for('application','js') and asset_paths.asset_for('anytimec','js') respectively. I've also compared those dumps to the same files from a fresh application. The fresh application does NOT prepend the "../javascripts" to the location whereas my current app DOES. It doesn't do this to the CSS files or anything else...just javascript. This is most definitely alluding to the core problem but I don't know where to go from here.

推荐答案

在读取资产文件夹中专门名为"java"的文件夹时,发现它与Sprockets失败有关后,我将其重命名为"applets",并将其重命名为"applets"开始工作.

After discovering that it had to do with Sprockets failing when reading a folder specifically called "java" in the assets folder, I renamed it to "applets" and it started working.

请参阅这篇文章答案.

这篇关于未预编译application.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆