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

  • SEARCH
  • Home
  • 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 6984595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:34:10+00:00 2026-05-27T18:34:10+00:00

I have an engine (developed by me / the company I work for) that

  • 0

I have an engine (developed by me / the company I work for) that we use on several different projects. I just converted it to work with rails 3.1 w/ assets pipeline and everything seems to be working… for the most part.

My problem is that I need to extend the functionality of the UsersController with a little bit of app-specific spice, but I’m not sure about the best way to do it. The engine doesn’t define a Users#show action, but this app does need it, so I added to the routes file:

JobEngine::Application.routes.draw do
  root :to => 'home#index'

  resource :users, :only => [:show]
  resources :jobs, :only => [:show]
end

Then in my application I created the UsersController:

class UsersController < MyEngine::UsersController
  def show
  end
end

Then I made a users/show.html.haml view, I’ve stripped it down to only show one of the problem lines:

= link_to "Somewhere", job_path(3)

This gives me an error that reads undefined method 'job_path' for #<#<Class:0x00000102d69900>:0x00000102d4ed30>

Which is bizarre because before I made my app’s UsersController inherit from MyEngine::UsersController it worked just fine.

When I do rake routes in the console, there are these lines:

users GET   /users(.:format)    {:action=>"show", :controller=>"users"}
job GET     /jobs/:id(.:format) {:action=>"show", :controller=>"jobs"}

I can alter the class definition to be:

class UsersController < ApplicationController

and then the link works just fine. However, the engine’s controller MyEngine::UsersController already inherits from ApplicationController. I can put code into my app’s ApplicationController (like a before_filter) and it will run as expected, so I know my class definition does ultimately hit my app’s ApplicationController, why is the job_path helper not working?

When I change the show action to read:

def show
  job_path(3)
end

I get the error:

ActionController::RoutingError (No route matches {:action=>"show", :controller=>"jobs", :id=>3}):
app/controllers/users_controller.rb:9:in `show'

Which further confuses me because now it actually does recognize job_path as a method, but somehow the router isn’t picking up where to go with all the correct parameters.

What am I doing wrong? What is the correct way to extend engine controller functionality? I saw the extending engine functionality question here.

And followed that code example, changing my class definition to instead re-open MyEngine::UsersController but I still get the exact same results concerning job_path(NUMBER)

UPDATE:

Ok I sort of figured out what’s going on. Let’s say your engine has a job_path route, and your application has a job_path route. If you’re on a page that was accessed via an engine’s controller, you can call the engine’s helper with just job_path, but you can also call the main application’s helper with main_app.job_path.

Likewise, if you’re on a page accessed via one of your application’s controllers, you access the engine’s helper with my_engine.job_path and your own application’s helper with job_path. This is assuming that you have something like mount MyEngine::Engine => "/my_engine", :as => 'my_engine'.

When you inherit an engine controller from your application, it then completely changes your route helpers to think you’re in the context of the engine through the controller/view lifecycle. So to fix my problem all I really have to do is change it to be main_app.job_path(3) and it works.

I’m not completely satisfied with this solution because it feels a little…weird. Maybe I have a partial on this page that will be used on a separate non-inheriting page. Now the link helper will only work for one of the two pages, but never both =\ Am I missing something here…?

  • 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-27T18:34:11+00:00Added an answer on May 27, 2026 at 6:34 pm

    Though you can make this approach work, the semantics do not create a clean architecture. You can surmise this from the duplication of the Users controller – which implies that some User functionality is handled in the AppEngine, and some is handled in the parent app itself.

    Instead, think about what functionality exists uniquely within the app, and which is packaged into the AppEngine gem. Perhaps with JobEngine, as you call it, your Users controller there is actually a UsersStatisticsController and, in the app, the controller there is the ‘true generic’ UsersController that handles CRUD, profiles, message queue, etc.

    If you feel you must unify them into a single controller (rather than giving them distinct nomenclature), then you are best to create a Namespaced controller, where the various functionality can be conjoined thereby.

    Even though this adds complexity, it’s generally arguable that this is the most sound solution. Here’s another post on SO about it

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

Sidebar

Related Questions

I use Solrnet to develop a search engine. In my application, I have a
I have a engine style Rails plugin from which I can create a gem
I have an XPath engine implementation that needs to be tested. Is there a
I have a game engine that uses OpenGL for display. I coded a small
I have a search engine that searches albums. For each music album, I have
I have this chess engine Rybka.exe, that i have to execute in java Here
I'm considering using JRuby on App Engine but have heard that Juby app on
I have some python code for Google App Engine that responds with the string
I have developed a web app a year ago aimed to work with IIS6.
We have a very lengthy newsletter that has been designed and developed to look

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.