Tri*_*rip 8 ruby-on-rails asset-pipeline
我看过几篇类似的帖子,但没有解决方案,所以我想我会提出一个更有记录的问题.
来自清单文件的我的问题 JS不包括或编译任何JS.
在本地运行我的服务器,并打开JS文件时,我看不到任何编译,只是标准的application.js清单文件:
// 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 underscore
//= require backbone
//= require backbone_rails_sync
//= require backbone_datalink
//= require backbone/myapp
//= require_tree .
Run Code Online (Sandbox Code Playgroud)
我的开发.rb:
MyApp::Application.configure do
config.cache_classes = false
config.whiny_nils = true
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.action_dispatch.best_standards_support = :builtin
config.active_record.mass_assignment_sanitizer = :strict
config.active_record.auto_explain_threshold_in_seconds = 0.5
config.assets.compress = false
config.assets.debug = true
end
Run Code Online (Sandbox Code Playgroud)
我的application.rb:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
Bundler.require(*Rails.groups(:assets => %w(development test)))
end
module MyApp
class Application < Rails::Application
config.encoding = "utf-8"
config.filter_parameters += [:password]
config.active_support.escape_html_entities_in_json = true
config.active_record.whitelist_attributes = true
config.assets.enabled = true
config.assets.version = '1.0'
end
end
Run Code Online (Sandbox Code Playgroud)
我的日志:
Started GET "/questions" for 127.0.0.1 at 2013-04-04 08:56:09 -0400
Processing by QuestionsController#index as HTML
Completed 200 OK in 204ms (Views: 16.0ms | ActiveRecord: 17.4ms)
Started GET "/assets/application.css" for 127.0.0.1 at 2013-04-04 08:56:09 -0400
Served asset /application.css - 304 Not Modified (2ms)
Started GET "/assets/application.js" for 127.0.0.1 at 2013-04-04 08:56:09 -0400
Served asset /application.js - 304 Not Modified (0ms)
Started GET "/assets/favicon.png" for 127.0.0.1 at 2013-04-04 08:56:09 -0400
Served asset /favicon.png - 304 Not Modified (0ms)
Run Code Online (Sandbox Code Playgroud)
需要注意的是,当我从MongoDB构建迁移到Postgres构建时,这个应用程序是从另一个应用程序中挑选出来的.所以我认为很可能,这与一些未经挑选的细节有关.
这个问题可以通过做..
$ rvm use ruby-2.0.0-p0$ rails new projectalert('hey')它在/assets/javascripts/$ rails s我认为这个问题是因为Ruby 2还没有与Rails一起使用:(
我将此正式定位为Ruby 2与Rails 3.2.6不兼容
小智 5
Rajesh的解决方案也对我有用.我使用的是2.0.0-p195和rake资产:生产时的预编译并没有真正读取application.js而我最终得到了文件应用程序 - ###.js,大小为1kb.
所以我回到了ruby 1.9.3,更新了捆绑包,手动清除了缓存
rm -rf tmp/cache/assets/*
rm -rf tmp/cache/sass/*
Run Code Online (Sandbox Code Playgroud)
然后
在我的application.js中,我有
//= require jquery
//= require bootstrap
//= require_tree .
Run Code Online (Sandbox Code Playgroud)
请注意,我不使用jquery-ui或jquery_ujs
然后我跑了
rake RAILS_ENV=production RAILS_GROUP=assets assets:clean
rake RAILS_ENV=production RAILS_GROUP=assets assets:precompile
Run Code Online (Sandbox Code Playgroud)
现在它有效.
我遇到了同样的问题,花了很长时间才找到解决方案。
我刚刚切换回ruby-1.9.3-p429,问题就解决了。我不知道如何管理它ruby 2 patches。我用过ruby-2.0.0-p247和ruby-2.0.0-p195。
所以,就这样做吧rvm use ruby-1.9.3-p429。然后运行“捆绑更新”。然后通过在控制台中运行来清除 Rails 缓存Rails.cache.clear,并且不要忘记清除浏览器缓存。
希望一切顺利。:)-
| 归档时间: |
|
| 查看次数: |
2955 次 |
| 最近记录: |