0

I am having an issue using a custom RackFilter setting and being able to correctly locate or leverage the rake:precompile function in production. My environment is as follows:

jruby 1.7.3
Rails 3.2.12

The rack filter mapping that I am using is as follows:

<filter-mapping>
    <filter-name>RackFilter</filter-name>
    <url-pattern>/r/*</url-pattern>
</filter-mapping>

To leverage the asset pipeline, without using precompile for development, I add the following to application.rb

config.assets.prefix = "/r/assets"

All of this works fine in development mode. The problems begin when I try to run the application in production mode. When I do a assets:precompile my assets directory structure looks like this:

/public/r/assets

and when I try and run the application I get the following error:

ActionView::Template::Error (application.css isn't precompiled):

which points me in the direction that the application is not correctly locating the manifest.yml file so I add the following to my production.rb:

config.assets.manifest = Rails.root.join("public/r/assets")

Which then I get the following error:

[WARN] 404 - GET /r/assets/application-3b09aaf17ec25843ede11b1160ca46ab.css

I have tried to change my production.rb to include:

config.assets.prefix = "public/r/assets"

but still get

[WARN] 404 - GET /public/r/assets/application-3b09aaf17ec25843ede11b1160ca46ab.css

So at this point I am running out of ideas and could use any suggestions or ideas. Thank you very much!

Lakota Lefler
  • 151
  • 3
  • 7
  • 1
    when you do a `bundle exec rake assets:precompile` it should not be creating a directory within another directory. What I believe you should have in your public directory is `public/assets`. Also have you tried doing `rake assets:precompile RAILS_ENV=production`. Also to be sure is the following set to `true` - `config.assets.compile = true` in your production.rb? – Deej Mar 20 '13 at 15:03
  • Thank you for the fast response @David. I moved my assets folder to reside in public/assets instead of public/r/assets. I also changed my configuration in my production.rb to use config.assets.compile = true , although, I did not want to change this setting in the first place because from what I have read this will really decrease performance. I am now getting an error: ActionView::Template::Error (File to import not found or unreadable: foundation/foundation-global. so I am doing my best to work through this to be able to determine if your solution will work. Thanks! – Lakota Lefler Mar 20 '13 at 15:32
  • Also, I believe that the assets:precompile is making the public/r/assets directory structure because of my config.assets.prefix = "/r/assets", which is needed since I am using the rackfilter of "/r/*" – Lakota Lefler Mar 20 '13 at 15:40
  • @David, so I added all of the required assets using config.assets.paths << Rails.root.join("dir", "dir" ...), I set config.assets.compile = true I removed config.assets.prefix = "/r/assets" from the application.rb to the development.rb so now the asset precompile RAILS_ENV=production creates the asset fold in public/assets. I still get the error: [WARN] 404 - GET /assets/application-3b09aaf17ec25843ede11b1160ca46ab.css, any other ideas? – Lakota Lefler Mar 20 '13 at 16:19
  • If you temporarily comment out `config.assets.paths << Rails.root.join("dir", "dir" ...)` Also have you got the following set to true: `config.assets.enabled = true` in your application.rb. Your application.rb should look something like this https://gist.github.com/anonymous/5206123 – Deej Mar 20 '13 at 16:33
  • it looks exactly like that except I do not have the line config.autoload_paths += %W(#{config.root}/lib) – Lakota Lefler Mar 20 '13 at 17:04
  • Well thanks for the help @David, still stuck. I will let you know if I figure anything out. Thanks again! – Lakota Lefler Mar 20 '13 at 18:42
  • Not sure how your production.rb is laid out but I have something like - https://gist.github.com/anonymous/5210465 – Deej Mar 21 '13 at 03:26

1 Answers1

0

The problem was that the public/assets directory needed to be located in the root of the war directory in order for tomcat to be able to locate the assets. So now the directory structure looks

Like this:

war
- assets
- META-INF
- WEB-INF

Instead of this:

war
- META-INF
- WEB-INF
- - public
- - - assets

Lakota Lefler
  • 151
  • 3
  • 7