Questions tagged [rails-engines]

A Rails engine allows you to share common functionality across applications in the form of a gem or a plugin. Engines can be considered miniature applications that provide functionality to their host applications.

A Rails engine allows you to share common functionality across applications in the form of a gem or a plugin. Engines can be considered miniature applications that provide functionality to their host applications.

Check http://guides.rubyonrails.org/engines.html and http://railscasts.com/episodes/277-mountable-engines for more details.

776 questions
23
votes
3 answers

How can I make routes from a Rails 3 engine available to the host application?

I have a Rails 3 application with several engines containing additional functionality. Each engine is a separate service that customers can purchase access to. I am, however, having a problem with routes from the engines that aren't readily…
20
votes
2 answers

Rails engine concerns autoload paths

I have some rails engine 'Core', and I have: # core/app/models/core/concerns/user_helper.rb module Core module UserHelper extend ActiveSupport::Concern included do # some methods end end end # core/app/models/core/user.rb module Core …
user1011792
19
votes
3 answers

How to test Rails 3 Engines with Cucumber & Rspec?

I apologize if this question is slightly subjective... I am trying to figure out the best way to test Rails 3 Engines with Cucumber & Rspec. In order to test the engine a rails 3 app is necessary. Here is what I am currently doing: Add a rails…
johnmcaliley
  • 11,015
  • 2
  • 42
  • 47
19
votes
2 answers

Override a Rails Engine controller action

i'm using a Rails engine, but i need to customize some controllers actions. I actually forked the engine, and implementing those customizations into my own fork, but i was wondering if there is an official way in Rails Engines to override and…
Marco Borromeo
  • 308
  • 1
  • 3
  • 7
18
votes
2 answers

Access to main app secrets from Rails engine initializer

I have been trying (unsuccessfully) to access the main app's application secrets from within my Rails mountable engine. The whole point of a mountable engine is to provide modularity. Therefore a common pattern would be to provide configurable…
18
votes
1 answer

Rails 3.2 Engine Layouts

I'm struggling to understand how Rails 3.2 applies layouts when using mountable engines. Scenario: I'm building an engine which itself has a dashboard view and an admin view for various admin functions. I want the dashboard to have its layout…
John Beynon
  • 37,398
  • 8
  • 88
  • 97
17
votes
2 answers

Routes in Engine mounted on subdomain do not inherit the constraints

Setup Our current Rails app is made out of sub-apps that are mounted as engines. Typically these engines are mounted on a subdomain in the main routes.rb file as follows mount MySubApp::Engine => '/', as: :sub_app, constraints: {subdomain:…
Aaron
  • 13,349
  • 11
  • 66
  • 105
17
votes
3 answers

Rails 3.1 Engines: Difference of my_engine.gemspec, add_dependency, add_development_dependency, and Gemfile

Just out of curiosity... in my previous post Rails3.1 engine: can't get SLIM or HAML to work in test/dummy app I asked where to tell Ruby to use some gem in my test/dummy application. The (obvious?) answer was to just put it into the Gemfile of my…
Joshua Muheim
  • 12,617
  • 9
  • 76
  • 152
16
votes
6 answers

Rails engines extending functionality

I have an engine which defines some models and controllers. I want to be able to extend functionality of some models/controllers in my application (eg. adding methods) without loosing the original model/controller functionality from engine.…
Andrius
  • 2,768
  • 3
  • 18
  • 13
16
votes
1 answer

No Route Matches ... Rails Engine

So I keep getting the error: No route matches {:action=>"create", :controller=>"xaaron/api_keys"} Which is thrown in the test: it "should not create an api key for those not logged in" do post :create expect(response).to redirect_to…
user3379926
  • 3,855
  • 6
  • 24
  • 42
16
votes
3 answers

Rails mountable engine: how should apps set configuration variables?

I have a mountable engine called Blog that apps can use. What's the best way to allow apps that use the engine to set a configuration variable like site_name (so that the engine can display it in the design)? Update: I've seen some gems create a…
Hopstream
  • 6,391
  • 11
  • 50
  • 81
15
votes
7 answers

Extending controllers of a Rails 3 Engine in the main app

I am using a Rails engine as a gem in my app. The engine has PostsController with a number of methods and I would like to extend the controller logic in my main app, e.g. to add some methods. If I just create PostsController in the main app, then…
Andrei
  • 10,918
  • 12
  • 76
  • 110
15
votes
1 answer

What is the best way to use webpacker in a Rails engine?

I realise there is some debate about using webpacker in Rails engines but I have a simple usecase and currently have a workaround. Would like to know of a better (the best?) solution. In this rails engine I have webpacker setup in the "spec/dummy"…
PropertyWebBuilder
  • 1,286
  • 2
  • 12
  • 18
15
votes
1 answer

How to use Middleware from an Engine in an Engine

Because of how the different gems interact in my system, I have an engine mounted onto a rails application. I recently started working on a new gem that provides some middleware functionality. Sort of like this: BaseApp \ Engine \ …
SortingHat
  • 727
  • 3
  • 15
  • 30
15
votes
5 answers

Using the correct url_for method in a Rails engine spec

I have a request spec in a Rails engine. The view that is rendered calls a route and passes in a hash, i.e. projects_path(:scope => "user"). A route like this will eventually call url_for, but url_for is defined in many places. When running the…
Samo
  • 8,202
  • 13
  • 58
  • 95
1
2
3
51 52