相关疑难解决方法(0)

Rails资产管道:包含所有/供应商/资产/ javascripts /的标准方式?

我一直在将应用程序转换为Rails 3.1(现在转到3.2)并在资产管道上观看Railscast.我将所有第三方jquery插件文件移动到/ vendor/assets/javascripts /目录.在我的/app/assets/javascripts/application.js中,我有以下内容:

//= require jquery
//= require jquery_ujs
//= require_tree .
//= require_self
Run Code Online (Sandbox Code Playgroud)

我意识到require_tree .调用只加载/ app/assets/javascripts /目录的树.(这是正确的吗?)包含所有 "供应商"javascripts 的最佳方式是什么?(我现在并不担心订购.)当然,我可以在/app/assets/javascripts/application.js中逐行索取.我的另一个想法是使用以下内容创建/vendor/assets/javascripts/vendor_javascripts.js:

//= require_tree .
Run Code Online (Sandbox Code Playgroud)

然后在/app/assets/javascripts/application.js中添加以下内容:

//= require vendor_javascripts
Run Code Online (Sandbox Code Playgroud)

这看起来有点笨拙.有没有更好的方法来自动包含所有"供应商"(和/或"lib")javascripts?

PS.我看到了关于index.js文件的内容,但我最终可能会得到多个名为index.js的文件,对吧?哦,我尝试重新启动我的服务器.

ruby-on-rails-3.1 sprockets asset-pipeline

53
推荐指数
2
解决办法
3万
查看次数

为什么我的rails资产管道中的js文件没有被编译?

我遇到了类似于这个问题的问题: Rails资产管道不包括application.js中的必需文件然而,这个问题已经关闭,所以我重新询问它,但是我的具体情况.)

环境:

Ruby 2.0.0,Rails 3.2.8,OSX 10.7.5,Chrome 28.0.1500.95

我遇到的主要问题

置于"/ app/assets/javascripts"中的文件似乎没有编译或出现在"/ public/assets"中

一个例子

如果我在app/assets/javascripts中放置一个这样的test.js文件:

  alert("Hello!");
Run Code Online (Sandbox Code Playgroud)

然后在我的应用程序中重新加载页面,此警报应该出现.(我正在复制Ryan Bates在资产管道上的Railscast中在~6:30进行视频时所做的事情)但是,没有出现警报.

调试尝试

我做了一些测试来尝试调试这个.

  • (所建议的下面@Aidan)如果我"室射频公共/资产",然后添加"javascript_include_tag'测试’"我的布局,警报不会 出现.但是,也许是因为我是n00b,我不知道这有助于我调试问题.
  • 如果我添加// = require_test到应用程序/ JavaScript的/ application.js中我的清单文件,这并不会导致警报出现.

我的清单文件(app/javascripts/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.
//
// …
Run Code Online (Sandbox Code Playgroud)

javascript ruby-on-rails asset-pipeline

21
推荐指数
1
解决办法
2万
查看次数

Rails 3.2.8 Application.js和Application.css不能正常工作

当我试图包括

<%= stylesheet_link_tag    "application" %>
<%= javascript_include_tag "application" %>
Run Code Online (Sandbox Code Playgroud)

application.css的文件内容是:

/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails sprockets ruby-on-rails-3.2 social-stream

11
推荐指数
3
解决办法
7463
查看次数