Skip to content

Usage of engine-specific route helpers in templates #192

@egor-khanko

Description

@egor-khanko

The gem always uses isolated_namespace-generated route helpers to generate links (example).
But according to Rails Guides this method is only relevant when we want to use isolated engine routes outside the engine.
In other cases Guides suggest to use just regular route helpers (from guides):

You also don’t need to use longer URL helpers like my_engine_articles_path. Instead, you should simply use articles_path, like you would do with your main application.

I think switching to using non-namespaced path helpers would simplify code a little and also resolve issues with embedding Lit::Engine inside a Rack::Builder app.
In our project we do that to protect UI's with HTTP Basic Auth using similar setup:

mount Rack::Builder.new do
  use Rack::Auth::Basic do |username, password|
    username == ENV.fetch('AUTH_USERNAME') && password == ENV.fetch('AUTH_PASSWORD')
  end
  run Lit::Engine
end

In this case we are getting undefined local variable or method 'lit' for #<#<Class:0x0000000102f039c8>:0x00000001034afde0> at app/views/layouts/lit/_navigation.html.erb#L12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions