Skip to content

Mounting the engine with a route constraint #92

Open
@olimart

Description

@olimart

Hey,

Albeit the mention of setting the base controller, I was trying to define a contraint while mounting the engine.
mount MissionControl::Jobs::Engine, at: "jobs", constraints: AdminConstraint.new

class AdminConstraint
  def matches?(request)
    return unless request.session[:user_id]
    User.find(request.session[:user_id])&.admin?
  end
end

which fails because <ActionDispatch::Request::Session:0x72ba0 not yet loaded>

I don't know if it's a limit of Rails engine (it used to work with Sidekiq dashboard though) or if there is some loading logic to change to make it work. Is that something that can be envisioned? Thanks

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