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 4327208
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:30:19+00:00 2026-05-21T09:30:19+00:00

I’m trying to break several pieces of reusable application functionality into Rails engines. I

  • 0

I’m trying to break several pieces of reusable application functionality into Rails engines. I have no trouble at all getting one engine to work, but the app doesn’t seem to load data from subsequent engines. I’m developing multiple engines simultaneously, so I’m requiring them into my testapp’s gemfile with the :path option.

Here’s my (simplified) setup (my understanding of the bare minimum to setup an engine with a simple model):

my_engines/engine1/lib/engine1.rb:

module Engine1
require 'engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
end

my_engines/engine1/lib/engine.rb:

require 'engine1'
require 'rails'

module Engine1
class Engine < Rails::Engine

end
end

my_engines/engine1/app/models/engine1/model1.rb:

module Engine1
    class Model1
    end
end

My second Engine, engine2 is setup identically and in the same parent directory (just with the name engine2 and the model model2).

I’m using jeweler to package and generate gemspecs for both engines, and I’m requiring both engines in a test application like so:

my_engines/testapp/Gemfile:

gem 'engine1', :path => '../engine1'
gem 'engine2', :path => '../engine2'

The weird thing is that when I fire up rails console for my testapp, Engine1::Model1.new works, but Engine1::Model1.new results in “NameError: uninitialized constant Engine2::Model2”. This seems to be true for all models, routes, controllers, etc. that I include into any subsequent engines. I’ve scoured the internet to no avail. Any thoughts?

  • 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-21T09:30:20+00:00Added an answer on May 21, 2026 at 9:30 am

    I think I’ve figured this out. Just in case anyone else out there happens to be playing with Rails3 engines (much recommended), and runs into this issue (hopefully not),
    the problem was having my engine.rb file and my engine_name.rb files
    both sitting side-by-side in the lib dir. The solution is to create
    an engine_name dir within lib and put your engine.rb file in there (I
    guess Rails only loads the first engine.rb file it finds in a gem or
    plugin’s lib dir). So…

    Bad (only loads one engine.rb in host app):

    /some_engine 
       |-- lib 
       |-- some_engine.rb 
       |-- engine.rb 
    

    Seems to work:

    /some_engine 
       |-- lib 
       |-- some_engine.rb 
       |-- some_engine 
           |-- engine.rb 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and
I am trying to render a haml file in a javascript response like so:

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.