asset-pipeline

Rails asset pipeline tests pass production broken

大兔子大兔子 提交于 2019-12-08 17:06:46
问题 I had the following problem with the asset pipeline. I have an HTML email with an image inside. I have tests covering the case in which the email is sent successfully. All tests pass. When going to production, the feature requiring the email to be sent is broken, because the HTML layout is referencing a non existent image. This obviously applies to all precompiled assets. It seems to me that suddenly tests are no longer reliable. Is there any way to avoid this situation to happen again? 回答1:

Do you add public/assets in version control?

做~自己de王妃 提交于 2019-12-08 15:48:53
问题 In rails 3.1, when you precompile the assets, rails create public/assets directory and add files there. Do you version-control public/assets/*? 回答1: I was looking for an answer to this too. I found the official Rails Guide has some thoughts on this: http://guides.rubyonrails.org/asset_pipeline.html#local-precompilation Here's a quote of the relevant section (emphasis added): There are several reasons why you might want to precompile your assets locally. Among them are: You may not have write

Rails 3.1: Intermittent 500 Internal Server Error when serving uncompressed assets

安稳与你 提交于 2019-12-08 12:04:26
问题 I'm upgrading an app to Rails 3.1. Quote often, Firebug will complain about some assets. Here are some errors pasted from Firebug: "NetworkError: 500 Internal Server Error - http://unstilted.dev/assets/jquery-ui.js?body=1" jquery...?body=1 "NetworkError: 500 Internal Server Error - http://unstilted.dev/assets/admin/pages/file_attachments.js" file_a...ents.js "NetworkError: 500 Internal Server Error - http://unstilted.dev/assets/admin/file_attachments/sortable.js?body=1" sortab...?body=1

NoMethodError thrown when trying to use controller variables in js.erb file

时光总嘲笑我的痴心妄想 提交于 2019-12-08 11:03:00
问题 In my assets, I have a file called maps.js.erb , basically with only the following (debugging) content: alert("<%= @map.width %>"); This JS file is loaded through the show.html.erb view belonging to maps. <%= javascript_include_tag params[:controller] %> <h1><%= @map.title %></h1> … The HTML file itself shows the map's title, e.g. when browsing to /maps/1/ , since @map is defined in the controller. However, as soon as I include the JS file, I get the following error: NoMethodError in Maps

Carrierwave + Nginx - Serving images from public directory

独自空忆成欢 提交于 2019-12-08 10:58:33
问题 How to config NGINX to serve uploaded carrierwave files from RAILS_ROOT/public/uploads ? e.g: http://deckbuilder.justnetwork.eu//uploads/card/image/173/54.png The files are getting served when config.serve_static_assets = true but this is slow. I want NGINX to serve them. The CS, JS and images are getting served. Here's a excerpt from my NGINX config: root /var/www/hsdeckbuilder/public; try_files $uri/index.html $uri.html $uri @app; location @app { proxy_set_header X-Forwarded-For $proxy_add

Rails precompile assets - Cannot access precompiled files locally

僤鯓⒐⒋嵵緔 提交于 2019-12-08 09:15:18
问题 I have a mysterious problem in my rails application, which I cannot fix. The thing is that I want to precompile my CSS and JavaScripts and run the server on the staging environment locally to check if everything is ok, before I deploy to the server. I run this command to precompile the files: rake assets:precompile RAILS_ENV=staging To start the server in staging environment i run this command: rails s -e staging The files are being precompiled successfully and placed in the public/assets

how to use tinymce content.css in rails

我是研究僧i 提交于 2019-12-08 05:59:35
问题 I need to provide tinymce a css file to take the styles from, but if I set in any file something like body{ font-size: 14px; } it will set the webapp's body to that style and not only tinymce's input box. How do I give tinymce a content.css file with the asset pipeline involved? 回答1: the proper format for this is to write body.mceContentBody { font-size: 14px; } or in TinyMCE 4.x (class name changed) body.mce-content-body { font-size: 14px; } and the tinymce (if using the gem) should be <%=

Images desapears after deploy Rails 3.1.3 on Heroku Cedar

耗尽温柔 提交于 2019-12-08 05:44:23
问题 After deploy on heroku cedar, images desapear. I've a CSS like : :css /* */ table.table thead .sorting { background: url('assets/datatables/sort_both.png') no-repeat center right; } table.table thead .sorting_asc { background: url('assets/datatables/sort_asc.png') no-repeat center right; } table.table thead .sorting_desc { background: url('assets/datatables/sort_desc.png') no-repeat center right; } /* */ table.table thead .sorting_asc_disabled { background: url('assets/datatables/sort_asc

javascript loading only after refreshing page

♀尐吖头ヾ 提交于 2019-12-08 05:23:08
问题 I'm using Rails 4. I have a javascript file, app/assets/javascripts/exotic_fonts.js, which adds some javascript functionality to fonts. When I load the homepage this javascript file is automatically loaded on the homepage, however it's not loaded automatically on other pages such as /user/show and the functionality is missing. However if I refresh the page, then the javascript file is loaded and the functionality is back. I was wondering how I can fix it. Also, is it possible to load only

Putting Javascript at the end of the file using Rails 3.1 asset pipeline

别来无恙 提交于 2019-12-08 04:07:12
问题 Sometimes in heavy client side Javascript we put the tags at the end of the HTML file so that the content is displayed first while Javascript is loaded afterwards. Is it possible to do this using Rails 3.1 assets pipeline? EDIT: <html> <head> <%= javascript_include_tag "application" %> </head> <body> <!-- all the page content goes here --> <!-- we include these at the bottom to ensure the html loads first and the javascript is loaded afterwards. How can we achieve this through rails asset