view helpers generating assets paths with engine prefix for parent application assets
Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/6597 Created by Damian Hamill - 2011-03-19 21:16:24 UTC
I want to create engines to embed in an application to add functionality but in most cases I want to use the parent application's layout and styles for a consistent look and feel. When accessing a view in an engine the assets included in the parent application's layout are prefixed with an auto generated engine prefix. I have an engine mounted at /svc with the following engine.rb file
module Svc
class Engine < Rails::Engine
config.asset_path = "/my_engine/%s"
end
end
and the following helper reference in {app.root}/app/views/layouts/application.html.erb
<%= stylesheet_link_tag "main" %>
When accessing /svc/index the output for this tag is
<link href="/my_engine//stylesheets/main.css" media="screen" rel="stylesheet" type="text/css" />
removing the config.asset_path setting gives
<link href="/svc_engine/stylesheets/main.css" media="screen" rel="stylesheet" type="text/css" />