4

I had put many css files in the file active_admin.css.scss :

// Active Admin's got SASS!
@import "active_admin/mixins";
@import "active_admin/base";
@import "admin/plugins/*";
@import "admin/calendar";
@import "jquery-ui.css";
@import "admin/jquery.datepick.css";

But the files "jquery-ui.css" and "admin/jquery.datepick.css" are creating problems. I am getting the 404 Not Found error in the browser console for below :

http://staging.xxx.com/assets/jquery-ui.css
http://staging.xxx.com/assets/admin/jquery.datepick.css

I also checked the assets in browsers, these 2 files are present, but they don't have content inside it. I am using Nginx as my webserver in Ec2. All is working in development, but not in production.

My Ngnix is configured as mentioned in this answer. I am using Capistrano to deploy. Everything is working but not those 2 files.

I have the below settings in production.rb too :

config.assets.compile = true
config.assets.precompile += %w[active_admin.css active_admin.js]

And still it didn't work. I found the above suggestion from here.

Community
  • 1
  • 1
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317
  • 1
    Have you precompiled them? – Richard Peck Jul 02 '15 at 11:35
  • Yes.. I did.. But I see somehow those files are not present in the server `current/public` directory.. I read this [post](http://stackoverflow.com/questions/24355795/css-doesnt-load-in-production-everything-fine-in-dev-rails-4-1-capistrano-3) also.. – Arup Rakshit Jul 02 '15 at 11:36
  • do you have a link to the staging server? – Richard Peck Jul 02 '15 at 11:38
  • @ArupRakshit I didn't mean to step on your answer with the record not found error question. You're one of good guys on SO. I found the asker so rude, I ended up deleting my answer after all. – Elvn Aug 24 '15 at 17:02
  • @ValAsensio Which answer you are talking about ? :) I forgot it seems – Arup Rakshit Aug 24 '15 at 17:07
  • @ArupRakshit Okay. Good. It was yesterday. I think yours was not an answer per se, but comments back and forth with the asker. I felt a little bit like I took over. – Elvn Aug 24 '15 at 17:53

2 Answers2

1

I don't know if this is a complete answer, but I can't post a formatted code snippet unless it's in the "answer" section, so here we go.

My theory is your missing files are not being included in your precompile and perhaps this would help. My assets .precompile statements are not in production.rb, rather are in assets.rb and look like this:

# assets.rb
# Be sure to restart your server when you modify this file.

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += %w( mapworkers.js )
Rails.application.config.assets.precompile += %w( prototype.js )

In production.rb

# production.rb
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_files = false

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

# Generate digests for assets URLs.
config.assets.digest = true

Additional debug idea: As a person wth 65k rep, I doubt you need my debug advice, but in particular my own Rails server setup is Nginx with Unicorn. I have been manually deploying because I my first deploy I wanted to get the app launched in the most direct manner, and then add complexity with components like Capistrano. If you find this problem intractable, cut out Capistrano altogether and deploy manually and see if you get your files where they need to be without it, then roll Cap back in and see if it breaks anything.

Elvn
  • 3,021
  • 1
  • 14
  • 27
1

Get rid of the file extensions in your @import declarations. It should be:

@import "jquery-ui";
@import "admin/jquery.datepick";
Marcelo De Polli
  • 28,123
  • 4
  • 37
  • 47