天道酬勤,学无止境

asset-pipeline

未检测到 Rails 预编译资产 Yarn 可执行文件(Rails precompile assets Yarn executable was not detected)

问题 我有一个从 Rails 5.0 转换为 Rails 5.1.0 的 Rails 项目。 当我尝试预编译资产时,我收到以下错误消息: Yarn executable was not detected in the system. Download Yarn at https://yarnpkg.com/en/docs/install 我从互联网搜索中读到的所有内容都说 yarn 和 webpacker 随 Rails 5.1 一起提供。 我从检查 rails 版本中得到以下信息。 $rails --version Rails 5.1.0 我该如何解决? 我也想知道发生了什么。 回答1 Rails 5.1 自带了对 yarn 和 webpack 的支持,但是你需要自己安装它们。 Yarn 是一个包管理器,而 webpack 是一个包。 按照 https://yarnpkg.com/lang/en/docs/install/ 上的说明在您的系统中安装 Yarn,然后将 webpack 添加到您的项目中,例如: yarn add --dev webpack webpack-dev-server 此外,您看到的消息是警告,而不是直接错误。 如果你不需要使用任何花哨的 js 包,你可以使用 good ol' asset pipeline 回答2 如果您不使用 yarn/webpacker

2021-12-02 01:06:36    分类:技术分享    ruby-on-rails   ruby-on-rails-5   asset-pipeline   yarnpkg

Static pages and assets in Rails 3.1.1

Currently working on a project where we need to drop in various static html pages + static assets for those from time to time that "just work." We cannot have anyone editing the html directly to place paths in for the assets. We need it to simply work such that the html + asset folders are placed directly into /public and the content is served up as it was generated. When testing this behavior in production, it's a no go with errors such as: ActionController::RoutingError (No route matches [GET] "/some_folder/some-image.png"): I assume this is a result from what I'm reading from 3.1.x's asset

2021-11-29 02:22:48    分类:问答    ruby-on-rails-3   ruby-on-rails-3.1   asset-pipeline

Ruby on Rails 4 javascript not executed

I have a custom js file in app/assets/javascripts. This is the js file: //app/assets/javascripts/contacts.js //$(document).ready(function() { //I've already tried with this method $(window).load(function() { alert("foo bar") }); I require the file contacts.js file in the application.js file. If I inspect the html page I see the js file loaded correctly, but the message is not shown. If I reload the page (by pressing f5), the message is correctly show. When the page is loaded the javascript is loaded (I can see it in source html code in the browser) but not executed. Can you help me? SOLUTION

2021-11-28 20:38:25    分类:问答    javascript   ruby-on-rails   ruby   ruby-on-rails-4   asset-pipeline

upgrade sass-rails gem to 5.0 gives deprecation warning

We upgraded to sass-rails version 5.0.0 and are getting this deprecation warning: DEPRECATION WARNING: Extra .css in SCSS file is unnecessary. Rename /Users/foo/Projects/foo/app/assets/stylesheets/foo.css.scss to /Users/foo/Projects/foo/app/assets/stylesheets/foo.scss. (called from _app_views_layouts_application_html_erb__1560597815210891605_70190441246060 at /Users/foo/Projects/foo/app/views/layouts/application.html.erb:13) Anyone know whats going on with this? Does the gem really want me to rename all of my stylesheet assets from: app/assets/stylesheets/foo.css.scss to: app/assets

2021-11-28 13:59:33    分类:问答    ruby-on-rails   sass   asset-pipeline

Grails Asset-Pipeline system with 3rd party libs

Grails 2.4 is now using the Asset Pipeline for managing and processing static assets in Grails applications instead of the Resources system. This is pretty new and there isn't much doc about it on the internet yet. My question is, how to correctly handle 3rd party libraries? For instance, the select2 (http://ivaynberg.github.io/select2/) library comes with all its .css, .js, image files in a single flat folder. Should I copy the different file types in to their corresponding assets/javascripts/, assets/stylesheets/, etc. subfolders? What to do with files that don't really have an obvious

2021-11-28 13:04:25    分类:问答    grails   asset-pipeline   assets

Rails 3 - 预编译文件夹中的所有 css、sass 和 scss 文件(Rails 3 - Precompiling all css, sass and scss files in a folder)

问题 所以我有一个具有特定页面样式和 css 的项目。 我已经将这些文件放到了它们自己的目录assets/#{type}/page-specific/并且我正在尝试编写一个正则表达式规则来通知预编译器对它们进行处理。 这对于房子的 JS 方面非常有效,但事实证明 css 更加困难。 # page specific style files: app/assets/stylesheets/page-specific/something.css.sass app/assets/stylesheets/page-specific/default.css app/assets/stylesheets/page-specific/home.css.scss 我在我的config/initializers/assets.rb文件中使用了这个正则表达式: Rails.application.config.assets.precompile << /(page-specific\/[^(css)]+.css)/ 问题是[^(css)]部分并不能完全满足我的要求,因为它会过滤掉任何包含 ac 或 s 的内容。 我真正在寻找的是一种匹配整个字符串“css”并停在那里的方法。 另外,我知道传统的观点是简单地以不需要页面特定样式表的方式编写样式,而是使用包含整个样式表的 application.css。

2021-11-28 12:14:15    分类:技术分享    ruby-on-rails   regex   asset-pipeline

Heroku is not pre-compiling my assets to prepare my app for asset pipeline

I'm having a bit of trouble getting my asset pipeline setup working with Heroku/Cedar using Rails 3.1.1 I've pushed my application and it launches successfully but there was no message that said "Preparing asset pipeline" and no static assets are being served up. No JS, CSS, or images are able to be found as there is no slug compilation time or runtime asset compilation being done. Any help would be greatly appreciated. They describe what should happen during deployment at this link which I'll summarize below: With a Rails 3.1 application on Heroku Cedar when you git push heroku your assets

2021-11-28 09:05:49    分类:问答    mongodb   ruby-on-rails-3.1   heroku   mongoid   asset-pipeline

Dynamic CSS in Rails asset pipeline, compile on fly

I'm building a site in Rails 3.2. Its been 3 years since I've touched Rails or Ruby, so I'm rusty on both, plus the last time I used rails is was Rails 2.3. Needless to say, please excuse any "simple" questions below. Here are the specs Multi Tennant CMS/Store Site http://company1.mywebsite.com http://company2.mywebsite.com etc. Each "Store" (aka sub-domain) can have its own look, feel, etc. through CSS customizations The customizations can be performed in a UI within the app allowing the user to change basic variables of Bootstrap (i.e. @textColor, @bodyBackground, etc.) I'm using the less

2021-11-28 08:42:05    分类:问答    ruby-on-rails   ruby   ruby-on-rails-3.2   less   asset-pipeline

How can I use Less in a Ruby on Rails 3.1 application?

What is the easiest (is there an easy way?) to use Less (in combination with Sass/Scss) in the Ruby on Rails 3.1 assets pipeline? I want to load a file like foo.css.less like I would do for bar.css.scss I found some wonky solution that does not work for me (haven't tried a lot): https://github.com/thisduck/ruby-less-js/issues/2 The idea would be to use Twitter Bootstrap in a clean way.

2021-11-28 08:10:21    分类:问答    ruby-on-rails-3.1   sass   less   asset-pipeline

ExecJS coffee script not showing line numbers for compile errors (Rails asset pipeline)

In one of my Rails apps, ExecJS is not showing line numbers for coffeescript compilation errors. My compile error message will look like this: ExecJS::RuntimeError in Referrals#new Showing ~/MyApp/app/views/layouts/application.html.erb where line #6 raised: SyntaxError: unexpected IDENTIFIER (in ~/MyApp/assets/javascripts/utils.js.coffee) Note that there's no line number for the coffee script source (line #6 is for the erb file). On another one of my apps, where I'm still getting the line numbers, a syntax error looks like this: ExecJS::ProgramError in Projects#show Showing ~/OtherApp/app

2021-11-28 06:49:36    分类:问答    ruby-on-rails   coffeescript   asset-pipeline   execjs