I\'m building an engine I\'ve bundled as a gem (gmaps4rails). I copied the /public of my engine in the /public of my rails app.
Everything works fine in development
In your engine, replace:
initializer "static assets" do |app|
app.middleware.use ::ActionDispatch::Static, "#{root}/public"
end
with:
initializer "static assets" do |app|
app.middleware.insert_before(::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public")
end
I don't know much about the way, gems are packaged/made. But why can't you copy the images/js/css stuff of your gems public folder into the apps public folder? I just did that and it worked for me. Is that not the done thing?
For performance reason, static assets serving is disabled in production mode. Your webserver should be configured to serve theses assets.
Look at this discussion if your are using nginx as a webserver.
In Rails 3.x try to set this in config/environments/production.rb
config.serve_static_assets = true
By default Rails assumes you are using an assets server (lightttp, nginx or Apache)
I had a similar problem mounting a Rails 3.1 engine. I was receiving blank assets in stage and production.
I found a solution at http://jonswope.com/2010/07/25/rails-3-engines-plugins-and-static-assets/comment-page-1/#comment-87 and tweaked it to suit Rails 3.1 asset locations:
initializer "static assets" do |app|
app.middleware.insert_before ::Rack::Lock, ::ActionDispatch::Static, "#{root}/app/assets"
end
I imagine there is a more elegant way but my effort today didn't yield anything substantial.
Have you tried adding this to your Rails::Engine class:
initializer "static assets" do |app|
app.middleware.use ::ActionDispatch::Static, "#{root}/public"
end
This will merge in your Gem's /public directory with the app at runtime.