Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6631679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:34:50+00:00 2026-05-25T22:34:50+00:00

I have a before_filter hook in my main app’s application controller that does something

  • 0

I have a before_filter hook in my main app’s application controller that does something like: (It doesn’t just put a link in the flash, there is a message, but it isn’t relevant to the question, it just accesses the route in the method)

class ApplicationController < ActionController::Base
  before_filter :set_link

  def set_link
    flash[:notice] = items_path
  end
end

This works fine for the app, however when I go into the controllers for an engine I made I get the exception

No route matches {:controller=>"items", :action=>"index"}

I understand that when in the engine, the routes helpers are for the engine unless prefixed with main_app

So changing the method in the application controller to

  def set_link
    flash[:notice] = main_app.items_path
  end

Gets rid of the exception but I really don’t want to have to do that. Is there another solution to getting the engine to recognize the main_app routes?

EDIT:

This also happens if the application layout calls path helpers. So if the engine is designed to integrated into the main_app’s layout then this issue will crop there up too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:34:51+00:00Added an answer on May 25, 2026 at 10:34 pm

    Mountable engines are designed to work like this, that is isolate the main app routes and the engine routes.

    If you want the two sets of routes to be merged, you can use a non-isolated engine. The first step is removing the isolated_namespace method call in your engine definition:

    module MyEngine
      class Engine < Rails::Engine
        isolate_namespace MyEngine # remove this line
      end
    end
    

    The second step is to convert your routes in my_engine/config/routes.rb, you should go from this:

    MyEngine::Engine.routes.draw do
      # stuff that routes things
    end
    

    to this:

    Rails.application.routes.draw do
      # stuff that routes things
    end
    

    and remove the mount method call in your application’s routes:

    App::Application.routes.draw do
      mount MyEngine::Engine => "/engine" # remove this line
    end
    

    The main advantages of doing it this way would be:

    1. No need to monkey-patch rails. I know devise does this, but this could be a leftover from the days when engines didn’t exist in rails.

    2. No need to mount the engine in the application routes. On the other hand, this could backfire if you’d like to control more precisely the insertion point as all you engine routes would be called after (or before, I don’t have the answer to this question) your main routes.

    If you’re looking for documentation on engines, the rails docs for the Engine class are a pretty good starting point. I’d strongly recommend that you read them (in case you haven’t yet) if you’re interested in the subject.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

say in my application controller, I have a before_filter that gets fired, loads some
I have a before_filter in my ApplicationController ; that is, for every controller in
I have a before_filter in my application controller to keep a user's session alive
in ruby you can have: class ApplicationController < ActionController::Base before_filter :require_login end i just
I have several before_filters defined in my application controller to handle requests I don't
One trick I have found very handy in rails application programming is that class_eval
In Ruby on Rails, I would like to add a before_filter to every controller
I'm using devise for authentication and have some before_filters in my application controller. Issue
I have this line in my votes controller: before_filter :authenticate So when I vote
I have a check_user_access_control before_filter in my ApplicationController that checks the logged user's roles

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.