FAQ Database Discussion Community


Rails 4 image_tag not loading Image from Assets

css,ruby-on-rails,image,ruby-on-rails-4,asset-pipeline
I have placed all my assets in the following folders app/assets/images/admin/* <---- Admin Template app/assets/images/default/* <----- Frontend Template Now when i am trying to use the following code <%= link_to image_tag('default/user-photo-medium-jpg', :class => 'media-object img-circle', :style => 'width: 64px; height: 64px;'), '#' %> It generated the following code and the...

NoMethodError on 'release_path' during chef deployment

ruby-on-rails-4,asset-pipeline,chef,aws-opsworks
I'm pretty new to Chef deployments, and I'm trying to deploy a rails app with OpsWorks. The trouble is with asset precompilation. I have this recipe to perform precompilations: execute "rake assets:precompile" do cwd release_path command "bundle exec rake assets:precompile --trace" environment "RAILS_ENV" => "production" end When I deploy with...

Requiring javascript from files overriding assets of a rails engine

ruby-on-rails,asset-pipeline,sprockets
I wrote a rails engine and want to be able to customize it in any application mounting it. [ENGINE/]app/assets/my_engine/application.js: //= require jquery //= require ./engine_specific //= require ./engine_customization [APP/]app/assets/my_engine/engine_customization.js: //= require selectize $(document).ready(function () { $('select').selectize(); }); This causes a js error (selectize is not a function) I tried requiring...

Does Phusion Passenger automatically precompile assets after restarting?

ruby-on-rails,asset-pipeline,passenger
Via git, I downloaded the latest version of my web-app to our server. I did a touch tmp/restart.txt but this didn't precompile my assets. I did a rake assets:clobber assets:precompile and this refreshed my assets. Is Passenger supposed to refresh my asset pipeline automatically? If it is, what are some...

How to Use Sprockets Gem Properly with Rails 4

ruby-on-rails,ruby,ruby-on-rails-4,asset-pipeline,sprockets
As a bit of pre-text, I am used to Rails 2 but started building a sample app to get used to Rails 4 and I am having a nightmare with Sprockets and the asset pipeline even after reading the official guide and every question I can find on SO. My...

Rails 3.2 Asset Pipeline + Custom Theme + Bootstrap

css,ruby-on-rails,twitter-bootstrap,asset-pipeline
Hoping someone can help me as I'm going crazy reading/attempting everything to get my CSS files loaded in production, but they either don't show or I get a 404 error. My 3.2 RoR app is using a mix of a purchased theme and bootstrap. Of course everything looks great in...

Rails shows the image URL rather then the image

ruby-on-rails,ruby,ruby-on-rails-4,asset-pipeline
I have a gridview of which the grid class (app/grids/users_grid.rb) includes the column below. However, the page does not show the image but instead shows the URL of the image. column(:name, :html => true, :mandatory => true) do |user| user.name + image_path("image.gif", title: "image", style: "max-height: 30px; max-width: 20px") end...

Referencing image asset as in-line CSS

ruby-on-rails-3.2,asset-pipeline,carrierwave
Calling an image as a background for a div dynamically, based on a stored image via the asset pipeline. Using carrierwave, the call would be <div class="row imaged-background" style="background:<%= image-url(@staticpage.image_url.to_s) %>"> However, this results in: undefined local variable or method `image Taking out <%= simply results in background: image-url(@staticpage.image_url.to_s)...

Rails 4: run application in production mode after assets precompile gives assets not found issue

ruby-on-rails-4,asset-pipeline,production-environment,ruby-on-rails-4.1
I am using rails 4.1.8 In production.rb file i have following: config.eager_load = false config.cache_classes = false config.consider_all_requests_local = true config.action_controller.perform_caching = true config.serve_static_assets = true config.assets.js_compressor = :uglifier config.assets.compile = false config.assets.digest = false config.assets.debug = true Now after running RAILS_ENV=production rake assets:precompile it precompiles all the assets and...

application.js not loading in Development (Uncaught ReferenceError: $ is not defined)

javascript,ruby-on-rails,ruby,asset-pipeline
Last week i was working with starting a new Ruby on Rails Application was going to build it in Rails 4 but had many complications so i uninstalled the rvm version of rails now one of my rails 3 project is having issues loading assets. (others are fine) I have...

adding background image in style rails 4

ruby-on-rails,twitter-bootstrap,ruby-on-rails-4,asset-pipeline
I am trying to add background image on my web page, it was working when I was using plane html, but now I am integrating it to my rails application. I am using this code to embed the image in my rails application <div class="jumbotron" style="background-image: "url(image-url('lines3.png')"; background-repeat: repeat-x; background-position:...

How to require other CoffeeScripts files in main CoffeeScript with Laravel?

php,laravel,coffeescript,asset-pipeline,laravel-elixir
I have one CoffeeScript project with "Ruby on Rails" framework. Now I want to use "Laravel" framework instead of "Ruby on Rails". In "Ruby on Rails", there is "Sprocket" asset pipeline management library. With "Sprocket", I can import other coffeescript files in main coffeescript file with #= require or #=...

Rails 4 asset pipeline in production

ruby-on-rails-4,asset-pipeline
My Rails app that I am upgrading to 4.2 from 3.2 has strange behavior in regards to the asset pipeline. The guide says to use: RAILS_ENV=production bin/rake assets:precompile which causes this error: Sass::SyntaxError: $red: "CC" is not a number for `rgba' (sass):86 ArgumentError: $red: "CC" is not a number The...

How to set a max-width as percent AND pixels?

html,css,css3,asset-pipeline
How can I prevent the width of a div from expanding beyond a percent AND a pixel? In other words, the browser should calculate the pixel value of the percent, and then choose the lower of the two values. If I were to set them both like this: {max-width:100px;max-width:20%;} the...

Can't add bower component css into assets pipeline in Rails 4.2

css,ruby-on-rails,angularjs,asset-pipeline,angular-ui-grid
I'm trying to add bower component (angular ui-grid) to my angularJS + Rails 4.2 application. The component is working fine in development env, but in production env it works without its css. I've installed the component via a bower to vendor/assets/bower_components and made the following changes in order to integrate...

Make in Grails a view load specific JavaScript using the Asset-Pipeline Plugin

javascript,grails,asset-pipeline
I render my views using a layout main.gsp. In main.gsp I specify the manifest file that I use for JavaScript: <asset:javascript src="application.js"/> In my asset-pipeline manifest file I have around 20 scripts. Some are used in some views, some not. But when the page is loaded all scripts are loaded....

How to add a UI kit (such as Get Shit Done) to an existing Rails project?

ruby-on-rails,bootstrap,asset-pipeline
I'm fairly new to Rails (and web development in general) and I'm trying to add the Get Shit Done UI Kit (GSD) to my existing Rails-Bootstrap app (with Bootstrap already installed using the bootstrap-rails gem). These are the files that come with this particular kit: x_get_shit_done --assets ---css -----demo.css -----get-shit-done.css...

How do I get a ready function and another function to play nicely in document.ready?

javascript,jquery,ruby-on-rails,ruby-on-rails-4,asset-pipeline
In my post.js, I have this: var ready; ready = function() { // This is the Sidebar toggle functionality var toggleSidebar = $(".togglesidebar"); var primary = $("#primary"); var secondary = $("#secondary"); toggleSidebar.on("click", function(){ if(primary.hasClass("col-sm-9")){ primary.removeClass("col-sm-9"); primary.addClass("col-sm-12"); secondary.css('display', 'none'); } else { primary.removeClass("col-sm-12"); primary.addClass("col-sm-9"); secondary.css('display', 'inline-block'); } }); }; $(document).ready(ready); Which...

Rails 4 - cannot change CSS without rake assets:precompile which breaks Javascript?

ruby-on-rails,asset-pipeline
If I make a change to application.css.scss, no changes are reflected unless I do rake assets:precompile. However, when I run that, none of the JavaScript in my application works. At that point, I have no way of getting the JavaScript to work unless I re-clone the application from GitHub (which...

Sometimes (unpredictably) my Rails application serves my assets with a digest. Sometimes, without

ruby-on-rails,nginx,asset-pipeline
Viewing source of my homepage: <link data-turbolinks-track="true" href="/assets/application-ea3565aaa6bc4c481fc9425308d6bd54.css" media="all" rel="stylesheet" /> <script data-turbolinks-track="true" src="/assets/application-2192d37159557835f39e5f3914e03276.js"></script> Then I refresh...from an "incognito" window: <link data-turbolinks-track="true" href="/stylesheets/application.css" media="all" rel="stylesheet" /> <script data-turbolinks-track="true"...

Rails 4 Heroku - changes not getting pushed?

ruby-on-rails,ruby-on-rails-4,heroku,amazon-s3,asset-pipeline
I am using Heroku to try to deploy a personal Ruby on Rails project and everything was going great until today. I am very very new to Ruby on Rails and Heroku so please bare that in mind. I am not sure what is causing my issue and therefore not...

Grails asset pipeline does not work seem to work for importing less files

grails,less,asset-pipeline
I am working with a Grails project that uses the Asset Pipeline. I have the following 1 css file and 2 less files... main.css /* *= require flex/xBrowserFlex.css *= require dashboard/dashboard.css */ xBrowserFlex.less .simple-column-flex{ display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; -webkit-flex-direction: column; -webkit-box-orient: vertical;...

Prevent Rails 4 Sprocket Asset Pipeline from caching a specific file

ruby-on-rails,asset-pipeline,sprockets
I have a file globals.css.scss.erb which only contains: <%= Styles.output %> Styles is a custom module to output formatted SCSS/SASS global variables based on a YAML file. My issue is that when I change the YAML file, globals.css does not get updated (i.e., it's cached by Sprockets). I want to...

Direct access to stylesheet with Rails

ruby-on-rails,asset-pipeline
I'm trying to enable direct access to this file: http://example.com/assets/style.css (located in /assets/stylesheets/style.css) It works in development, but I get a 404 error in production. config/initializers/assets.rb: Rails.application.config.assets.version = '1.0' Rails.application.config.assets.precompile += %w( static_pages.css ) Rails.application.config.assets.precompile += %w( dashboard.css ) Rails.application.config.assets.precompile += %w( style.css ) config/initializers/production.rb: config.cache_classes = true config.eager_load =...

Rails 4.1 assets pipeline production, background image path different in two seperate css files after precompile

asset-pipeline,ruby-on-rails-4.1
I have a rails 4.1.1 application in production, in that i have a fancybox.css file from the gem 'fancybox2-rails', '0.2.8' In the application.css i have added the file as below. *= require jquery.ui.datepicker *= require jquery.ui.slider *= require fancybox *= require_tree . *= require_self Also in another lockbox.css file i...

Heroku breaking my Rails + Angular.js app via JS file minification

javascript,ruby-on-rails,angularjs,heroku,asset-pipeline
I have a brand new Rails 4.2.0 app with Angular.js on Heroku and I have the following angular.js controller: angular.module("CarDealer.controllers",[]).controller('carsController', function ($scope, carDealerAPIservice) { $scope.nameFilter = null; $scope.carsList = []; carDealerAPIservice.getCars().success(function (response) { $scope.carsList = response; }); }); and in my view: <div class="row" data-ng-controller="carsController"> <div class="row"> <div class="col-md-4"> <input...

How to change styling on rails-generated outputs

ruby-on-rails,twitter-bootstrap,asset-pipeline
I am using twitter bootstrap installed by copying bootstrap.min.css, etc. into the vendor/assets folder. When using rails forms validations, error messages appear using default styling, not the bootstrap styling I would expect (e.g. the h2 tag is much smaller and in a different text, the unordered list uses different bullets,...

Precompiling assets for a multi-homed Rails application

ruby-on-rails,asset-pipeline,sprockets
I have a multi-homed Rails 3.2 application where each "home" has its own skin. The assets for these are precompiled using a custom Rake task: require "fileutils" namespace :assets do namespace :precompile do task :homes, [:short_name] => ["assets:environment"] do |t, args| include Sprockets::Helpers::RailsHelper homes = args.short_name ? home.where(:short_name => args.short_name)...

Accessing Grails asset pipeline from Config.groovy

grails,ckeditor,asset-pipeline
I have recently updated my Grails app to 2.4.4 and am now using the asset-pipeline plugin. I am also using the CKEditor text editor plugin. CKEditor loads its configuration from a Javascript file, ckconfig.js, which I have stored in /assets/javascripts/ckconfig.js. Loading of this file is declared in Config.groovy: // CKeditor...

Why doesn't my CSS work on my Rails app?

javascript,html,css,ruby-on-rails,asset-pipeline
I am new to Rails and have been struggling to fix this issue despite searching for an answer. I have created a new app and I am trying to migrate a Theme Forest Bootstrap template into the app. I thought it would be quite simple but I have failed so...

Why are my assets not loaded the way I want them to be - development mode. rails 4.2

ruby-on-rails,ruby-on-rails-4,asset-pipeline
I am unsure if there is a setting in rails 4.2 that changed from 4.1, or if I am just crazy sauce. But this is my application.js file: // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // //...

Precompiling rails assets caused undefined method directory? for nil:NilClass

ruby-on-rails,asset-pipeline,assets,precompile
I am trying to precompile assets in my rails app, and getting this $ ber assets:precompile --trace DL is deprecated, please use Fiddle DL is deprecated, please use Fiddle ** Invoke assets:precompile (first_time) ** Invoke assets:environment (first_time) ** Execute assets:environment ** Invoke environment (first_time) ** Execute environment ** Execute assets:precompile...

Rails 4 - Bootstrap and CSS not showing on production server

ruby-on-rails,twitter-bootstrap,asset-pipeline
The bootstrap and CSS work perfectly in development for our rails 4.2 app. Here is the login page in development: After deploying (ubuntu 14.1), assets are precompiled with: bundle exec rake assets:precompile RAILS_ENV=production However the bootstrap and css are completely not showing any effect on production server. Here is the...

Precompiling assets with Rails_Env set as production

sql,ruby-on-rails,ruby-on-rails-4,heroku,asset-pipeline
I'm trying to run $ rake assets:precompile RAILS_ENV=production in order to: 1) minify my assets (following this answer: How do I minify CSS in Rails 4?) and 2) use the production level variables in my JS (i.e., my JS has ENV['variable'] and when I run a regular rake assets:precompile and...

rails broken on production mode and asset pipeline kills my app

ruby-on-rails,ruby-on-rails-4,asset-pipeline
rails broken on production mode and asset pipeline kills my app This is the webpage, shows the error directly, I don' think the error in assets should break my app (annoyed Rails) The assets files works really perfectly in static. But really troublesome to migrate into Ruby on Rails application.rb...

Stylesheets not working on Heroku

html,css,ruby-on-rails,heroku,asset-pipeline
I've been trying to get my CSS to work correctly in my Rails app. I just added config.serve_static_assets = true to my config/application.rb to try to get the assets to precompile. Before some of the CSS was working but not enough, and now all of the styling has been removed...

Prevent Grails Asset-Pipeline from changing File Name?

grails,asset-pipeline,grails-plugin
I use Grails 2.4.4 and the asset-pipeline plugin. One of my assets is a PDF file. I want that the name someName.pdf while remain when a user downloads this file. In my GSP I use it as: <a href="${assetPath(src: 'someName.pdf', absolute:true)}" target="_blank">Download PDF</a> When I run in production the downloaded...

Rails App: pipeline asset not working as expected

css,ruby-on-rails,ruby-on-rails-4,sass,asset-pipeline
I'm a ruby and rails novice so please have patience with me. I have a SASS file (stats.css.scss) in rails that is loaded correctly in my development enviroment, but doesn't get loaded in my production enviroment. I know is the asset pipeline that is causing this, but have made several...

Rails asset pipeline strips out plugin copyrights

ruby-on-rails,asset-pipeline
I have some vendor files in my application that contain copyright information that needs to be visible if someone were to look at the source file. But when asset pipeline runs, it strips all of that out. Is there anyway to not remove the copyright information?