Domanda

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!

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top