asset-pipeline

Why does rake assets:precompile in development cause problems but not in my production environement

落爺英雄遲暮 提交于 2019-12-05 14:06:33
I have upgraded my app on heroku to a cedar stack so that the asset pipeline works. I have followed the instructions given in heroku's docs by choosing to compile assets locally. This has created a directory public/assets. Everything in production works perfectly(css, js, with no problems). Going back to my development environment seems to cause the js to not function properly. In environments/production.rb config.serve_static_assets = false config.assets.compress = true config.assets.compile = true config.assets.digest = true In environments/development.rb config.assets.compress = false

Include Assets Only If They Exist

霸气de小男生 提交于 2019-12-05 13:51:46
问题 In our current rails app, we are following certain patterns for including assets such as scripts and stylesheets. For instance, one such pattern is (code inside the layout): = stylesheet_link_tag controller.controller_name The problem here is that not all of the controllers are going to have associated stylesheets. What is the best way to check if an asset exists? Specifically, I know there is some trickery here due to the cache busting asset names. 回答1: Finally figured this one out. Asset

How do I reference a static HTML rsource using the Grails Asset plugin?

与世无争的帅哥 提交于 2019-12-05 13:38:37
I am using Grails 2.4.1 and the Grails Asset Pipeline Plugin version 1.9.7. I have a javascript file (it defines an AngularJS directive) which needs to reference a static HTML file (which will be used as the template for the AngularJS Directive). How do i reference the HTML file within the asset directory? Project Structure: grails-app assets javascripts directives hierarchyviewer.js hierarchyviewer.html Project Structure when using the Angular Template Asset pipeline grails plugin grails-app assets javascripts directives hierarchyviewer.js templates hierarchyviewer.tpl.html directivea.js

How to properly work with jQuery in Rails 3.1 asset pipeline?

陌路散爱 提交于 2019-12-05 11:30:19
问题 I'm working on a hobby app and using some jQuery. The results are fine at the moment, but I'm a jQuery noob and I assume that there are some significant improvements that I can make to the code structure. Putting aside Coffescript for the moment, one thing that I've been wondering is how to properly use the model-specific .js files in the asset pipeline. For example, when working with my User model, I may have some code that I want to have run when the document is ready. Let's say I put that

Enable image caching in development mode in Rails 3.1

倾然丶 夕夏残阳落幕 提交于 2019-12-05 10:51:59
In Rails 3.1 development mode (when using the asset pipeline), images served out of assets/images are served up with the response header "Cache Control: must-revalidate". This means that Google Chrome (and seemingly only Chrome) will attempt to re-fetch images numerous times—even during a single page view. This has resulted in screwy issues with all manners of DOM manipulation via JavaScript. To name a few: jQuery UI Draggable sometimes features a dramatic offset from the mouse cursor Adding or removing a CSS class that references an image will flash or resize while the image request (which

Capistrano deploy - assets precompile error

痴心易碎 提交于 2019-12-05 08:45:06
I am deploying with Capistrano to my new VPS. After the first deploy(cap deploy) everything was OK (site was running), but the second deploy failed on assets:precompile error. I am running rails 3.2.13, ruby 2.0.0, rvm. error: * executing "cd -- /home/rails/releases/20140116121250 && RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile" servers: ["IP"] [IP] executing command *** [err :: IP] bash: line 1: 23406 Killed RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile command finished in 84187ms *** [deploy:update_code] rolling back * executing

What is the convention in Rails (with asset pipeline) for internationalization inside CSS?

烈酒焚心 提交于 2019-12-05 08:02:57
I know CSS isn't supposed to have content, but it does, like this nice box (below) extracted from the Twitter Bootstrap documentation CSS: /* Echo out a label for the example */ .bs-docs-example:after { content: "Example"; } I don't care for "Example", I use something like that as a mixin: .box (@legend) { /* Echo out a label for the example */ &:after { content: @legend; } } Then I don't need really dynamic CSS, I can easily include the mixin in a class, but instead of passing "Observation" I need to pass t 'box.observation' : .observation { .box("<%= t 'box.observation' =>"); } Rails is

In Rails how to check if javascript file exists before using javascript_include_tag

你。 提交于 2019-12-05 07:28:35
In a rails 3.2 app, I would like to check for the existence of a javascript file in the asset pipeline before including the javascript_include_tag in a file. Something like: <% if javascript_file_exists? %> <%= javascript_include_tag "#{controller_name}_controller" %> <% end %> I would like to do this so that the absence of a javascript file will not result in an error. Is there a way to do this? A more Rails way is to use a helper. This allows you to check for a coffeescript or a javascript version of a file: def javascript_exists?(script) script = "#{Rails.root}/app/assets/javascripts/#

Rails app on percise32 vagrant box - assets get “text file busy” error (Errno::ETXTBSY)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 05:26:04
Trying to boot up a Rails app inside a Vagrant box (percise32) host machine is Windows 7. This is my Vagrantfile Vagrant.configure('2') do |config| config.vm.box = 'precise32' config.vm.box_url = 'http://files.vagrantup.com/precise32.box' config.vm.hostname = 'rails-dev-box' config.vm.synched_folder "c:\rails_text", "/home/code" config.vm.network :forwarded_port, guest: 3000, host: 3003 config.vm.provision :puppet do |puppet| puppet.manifests_path = 'puppet/manifests' puppet.module_path = 'puppet/modules' end end When i try to run the app (code is syncing correctly) i am getting the following

How can I specify an alternative directory for my HandlebarsJS templates with the ember-rails gem?

浪尽此生 提交于 2019-12-05 05:16:43
I have a Rails application, and I'm using Ember on the front-end. I'd like to move the ember-related files down one level in the directory structure, but when I do, the templates no longer render. In the plain, vanilla, working version of the application, my directory structure is: ./app/ assets/ javascripts application.js ember-app.js routes.js store.js models/ controllers/ routes/ templates/ views/ with: application.js //= require jquery //= require jquery_ujs //= require handlebars //= require ember //= require ember-data //= require_self //= require ember-app App = Ember.Application.create