Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

view helpers generating assets paths with engine prefix for parent application assets

#6597

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" />

Reported by Damian Hamill · March 19th, 2011 @ 09:16 PM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

No comments yet.