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
121
votes
5 answers

Rails 3.1: Engine vs. Mountable App

Can someone help me understand the differences between a Rails Engine and a Mountable app? In Rails 3.1, you can create either one with the "rails new plugin ___" command. rails plugin new forum --full # Engine rails plugin new forum…
61
votes
11 answers

Ruby on Rails 3 - Reload lib directory for each request

I'm creating a new engine for a rails 3 application. As you can guess, this engine is in the lib directory of my application. However, i have some problems developing it. Indeed, I need to restart my server each time I change something in the…
Nicolas Guillaume
  • 7,002
  • 6
  • 33
  • 42
49
votes
7 answers

Rails Engine - Gems dependencies, how to load them into the application?

I'm doing an engine here, it works alright in stand alone. When I transform it into a gem, and load it inside another application, I get a lot of undefined errors, coming from my engine gem's dependecies. Here is the…
Tiago
  • 2,808
  • 4
  • 31
  • 41
44
votes
3 answers

Named routes in mounted rails engine

I'm making a small rails engine which I mount like this: mount BasicApp::Engine => "/app" Using this answer I have verified that all the routes in the engine are as the should be: However - when I (inside the engine) link to a named route (defined…
Markus
  • 2,306
  • 3
  • 23
  • 34
39
votes
6 answers

Migrations in Rails Engine?

I have multiple rails applications talking to the same backend and I'd like them to share some migrations. I setup a rails engine (with enginex), I can share anything (controllers, views, models,...) but no migrations. I can't make it work ! I tried…
Mike
  • 5,005
  • 6
  • 32
  • 49
37
votes
2 answers

Testing Rails 3.1 mountable engine with Rspec

I started making a Rails 3.1 engine, and I'm having a hard time testing it using rspec. First of all, if I run rails g integration_test whatever it creates a regular integration test in tests/integration instead of spec/requests (the rspec-rails gem…
deb
  • 11,136
  • 19
  • 62
  • 83
31
votes
1 answer

Difference between add_dependency and add_runtime_dependency?

What is the difference between using add_dependency and add_runtime_dependency in a Rails engine's gemspec? For example: Gem::Specification.new do |s| s.add_dependency 'jquery-rails' s.add_runtime_dependency 'jquery-rails' end What's the…
Jacob
  • 5,787
  • 9
  • 35
  • 56
31
votes
3 answers

How to add dependency of a local gem to a rails plugin/engine, in .gemspec file

I had tried in this way: s.add_dependency 'gem', :path => '../gem' like add gem in the gemfile, but it doesn't work, and will cause this error: /Users/chenqh/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:81:in…
31
votes
3 answers

Render engine within application layout

Background I am creating a application that is made up of a core and several modules. The modules are rails engines, and provide the actual functionality as the core itself only acts as a host. The engines are hosted from /lib and mounted at their…
Jørgen R
  • 9,179
  • 7
  • 36
  • 56
29
votes
2 answers

Differences between railties and engines in Ruby On Rails 3

I read a few documents on these arguments, but I did not understand clearly what they are, what are the differences between them and if one of them fits my needs. I need to write a piece of application which can be plugged in other application and I…
Fabio
  • 17,633
  • 9
  • 76
  • 110
26
votes
5 answers

Rails 3.1: Better way to expose an engine's helper within the client app

I have found a few articles addressing the issue of helpers within an engine not being accessible to the consuming (parent) application. To make sure we are all on the same page, let's say we have this: module MyEngine module ImportantHelper …
ynkr
  • 20,186
  • 4
  • 30
  • 30
25
votes
1 answer

How to generate a dummy app inside an already existing rails engine

I came to work for a company recently that has been working on a specific rails project for a while. Dropped in the middle of the development process, I'm beginning to go back and write tests for the existing code as well as the code currently being…
24
votes
5 answers

Access Main App Helpers when overridings a Rails Engine View/Layout

I have created a simple Rails Engine to provide some general functionality(photo gallery) to an application. I want to be able to override the standard _header partial so that the menu for the gallery matches that of my main application. In my…
23
votes
6 answers

Listing 'rake routes' for a mountable Rails 3.1 engine

I'm working on a mountable engine for use with Rails 3.1, and I want to list the engine's routes. I created the engine using: $ rails plugin new rails_blog_engine --mountable And edited the 'test/dummy/config/routes' file to…
emk
  • 56,152
  • 6
  • 40
  • 49
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…
1
2 3
50 51