sprockets

Rails dev environment not updating html/css/assets even after restarting server

做~自己de王妃 提交于 2019-12-03 23:39:48
I've been developing a site in rails, everything going relatively smooth. Suddenly my changes to the views and assets no longer show up. I change a stylesheet or some html and reload my browser at http://0.0.0.0:3000 and nothing changes. So I restart WEBrick and still nothing's changed. This is even the case if I change an image entirely. The only way to get the new changes is to precompile the assets: C:\Users\me\website>rake assets:precompile C:/Ruby193/bin/ruby.exe C:/Ruby193/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets Why is it showing production as the RAILS

Serving assets is very slow in development

喜夏-厌秋 提交于 2019-12-03 20:32:40
I have a standart rails 3 webapp with the default asset pipeline. All of a sudden, the assets took a very long time to load (my page loads went to ~1-2secs to ~1min). The server response time (/home) is normal, but some .css and .js files are pending for very long (up to 45 seconds). The only few assets that take this long are those provided by gems (eg: modernizr-rails/vendor/assets/javascripts/modernizr.js ) For example, for modernizr.js?body=1 : Headers: Request URL:http://dev.sharewizz.com:3000/assets/modernizr.js?body=1 Request Method:GET Status Code:304 Not Modified Stats: DNS Lookup 5

Rails asset pipeline and digest values

送分小仙女□ 提交于 2019-12-03 14:47:31
Does anyone know how exactly the asset digest value is calculated? If I have two JS files which contain various other included JS scripts then will each file maintain the same digest hash if none of the inner scripts have been changed? Or is a new digest value calculated each time the assets:precompile operation is run? Grabbed from rails guides When a filename is unique and based on its content, HTTP headers can be set to encourage caches everywhere (whether at CDNs, at ISPs, in networking equipment, or in web browsers) to keep their own copy of the content. When the content is updated, the

Full Asset URL in a Rails .js.erb file

喜你入骨 提交于 2019-12-03 14:41:42
I have a bookmarklet that can be loaded on any website. It works like this; loads http://my.example.com/assets/bookmarklet.js includes http://my.example.com/assets/bookmarklet.css The css file is added to the dom via bookmarklet.js , so it needs to know where this is. My code is as follows; // assets/javascripts/bookmarklet.js.erb var config = { stylesheetUrl: '<%= asset_path("bookmarklet.css", :only_path => false) %>' } But no matter what I try this renders as var config = { stylesheetUrl: '/assets/bookmarklet.css' } I need the asset_path to return a full url. But asset_url doesn't exist, and

SASS, Rails 3.1: Loading stylesheets in vendor/assets

时光怂恿深爱的人放手 提交于 2019-12-03 12:08:32
问题 I'm using SASS to load stylesheets in a Rails 3.1(sass-rails 3.1) app. For example, sass partials in app/assets/stylesheets are loaded using @import in application.sass - @import "pages/common" @import "pages/**/*" @import "jquery-ui.css" Now, I also want to load vendor/assets/stylesheets . Note that I'm not using require vendor , as @import pages/* seems to be the sass recommended way of doing it. Files here will be css , and not sass or scss . I cannot use @import ../../../vendor/assets

Documentation for creating custom Sprockets processors?

喜欢而已 提交于 2019-12-03 12:04:30
I'm trying to create a sprockets preprocessor for Rails that finds .png.rb files in the asset pipeline and uses them to generate png screenshots of various pages in my application. I've read up on this topic quite a bit but I can't seem to find any straightforward documentation on how to get this set up. Help, please? Here's what I have so far: /initializers/sprockets.rb : require 'screenshot_preprocessor' Rails.application.assets.register_mime_type('screenshot/png', '.png.rb') Rails.application.assets.register_preprocessor('screenshot/png', ScreenshotPreprocessor) /lib/screenshot_preprocessor

Rails Assets Best Practices [closed]

一曲冷凌霜 提交于 2019-12-03 11:24:39
I'm new to Rails, and having trouble figuring out the best way to organize my assets. The purpose of this question is to collect my thoughts, solicit input, and evolve the document over time - perhaps it can be a Rails Guide someday. (The Rails Wiki appears to be dead.) This will be meant as an aid to conceptualization for novices, not a reference, so it will be limited to the most common scenarios. Asset Pipeline - Overview For details on the purpose, benefits, and inner workings of the pipeline, start with this guide: http://guides.rubyonrails.org/asset_pipeline.html I will only summarize

How to override single files from gem assets for assets:precompile?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 11:19:38
Situation I use a gem that brings its own JavaScript and stylesheet assets. This gem uses a standard application.js and application.css manifest to require all its assets: [gem]/app/assets/javascripts/gem_name/application.js require_tree . [gem]/app/assets/javascripts/gem_name/backoffice/menu.js … some JavaScript code … [gem]/app/assets/javascripts/gem_name/backoffice/forms.js … some JavaScript code … In development mode I can then override single asset files by placing them in [my_app]/app/assets folder, e.g.: [my_app]/app/assets/javascripts/gem_name/backoffice/menu.js The load paths

What sprockets mean in rails

徘徊边缘 提交于 2019-12-03 10:45:16
问题 So, I just realised that I have absolutely no Idea what Sprockets are in rails. when using either bootstrap, or materialize, it is requested to include the sprocket (bootstrap-sprocket or materialize-sprocket) in the application.js file. Everything I search talks about the asset pipeline and confuses me the more. According to ruby-guides, The asset pipeline is technically no longer a core feature of Rails 4, it has been extracted out of the framework into the sprockets-rails gem. and when I

How do I get escape_javascript and other helpers in my sprockets pre-processed js file (not a view)?

只愿长相守 提交于 2019-12-03 10:30:38
I'm using Rails 3.1 and the sprockets stuff. I want to use ERB to pre-process a js file that will then be included using javascript_include_tag. It is generated from code, and so I'm pre-processing it with ERB, but I can't get to the helpers like escape_javascript from ActionView::Helpers::JavaScriptHelper Say my file is called dynamic.js.erb, and it contains obj = { name: "test", tag: "<%= escape_javascript( image_tag( "logo.png" ) )%>" }; How do I stop it from producing the error: throw Error("NoMethodError: undefined method `escape_javascript' for #<#<Class:0x1067da940>:0x116b2be18> (in