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.

762 questions
23
votes
2 answers

Creating a gem that contains rails models

I've been reading a lot on the topic and nothing seems to quite cover my needs. I'm sorry if I'm repeating or unclear about something I'm both new to ruby and rails and new to stackoverflow. I have an existing rails application with a lot of…
Shrewd
  • 711
  • 5
  • 14
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
  • 10,779
  • 1
  • 39
  • 47
19
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
18
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
  • 233
  • 3
  • 7
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
  • 36,235
  • 7
  • 79
  • 92
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
  • 10,965
  • 6
  • 61
  • 127
16
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
  • 10,807
  • 7
  • 58
  • 102
16
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
  • 7,964
  • 9
  • 53
  • 91
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
  • 9,162
  • 7
  • 68
  • 103
15
votes
0 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…
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
  • 649
  • 1
  • 12
  • 28
15
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,708
  • 3
  • 16
  • 13
15
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,527
  • 5
  • 22
  • 40
15
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
  • 5,893
  • 9
  • 47
  • 77
13
votes
5 answers

Engine routes in Application Controller

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…
Kyle d'Oliveira
  • 6,052
  • 1
  • 22
  • 32
1
2
3
50 51