diff options
author | Ryan Bigg <radarlistener@gmail.com> | 2011-10-06 08:47:06 +1100 |
---|---|---|
committer | Ryan Bigg <radarlistener@gmail.com> | 2011-10-06 09:18:21 +1100 |
commit | 876d3f23d2370790623c6ef261d7c2366fb404d3 (patch) | |
tree | b206e98251f986b075fcbcc9739ee822de8a9c31 /railties/guides/source | |
parent | 1ba6b406981892f3501bc6a345573fd861641f9a (diff) | |
download | rails-876d3f23d2370790623c6ef261d7c2366fb404d3.tar.gz rails-876d3f23d2370790623c6ef261d7c2366fb404d3.tar.bz2 rails-876d3f23d2370790623c6ef261d7c2366fb404d3.zip |
[engines guide] More explanation for 'Generating an engine'
Diffstat (limited to 'railties/guides/source')
-rw-r--r-- | railties/guides/source/engines.textile | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/railties/guides/source/engines.textile b/railties/guides/source/engines.textile index 83672fd66c..ddd2e50a6c 100644 --- a/railties/guides/source/engines.textile +++ b/railties/guides/source/engines.textile @@ -34,10 +34,28 @@ The +--mountable+ option tells the plugin generator that you want to create an e Inside the +app+ directory there lives the standard +assets+, +controllers+, +helpers+, +mailers+, +models+ and +views+ directories that you should be familiar with from an application. -Within the +app/controllers+ directory there is a +blorgh+ directory and inside that a file called +application_controller.rb+. This file will provide any common functionality for the controllers of the engine. The +blorgh+ directory is where the other controllers for the engine will go. By placing them within this namespaced directory, you prevent them from possibly clashing with identically-named controllers within other engines or even within the application. +At the root of the engine's directory, lives a +blorgh.gemspec+ file. When you include the engine into the application later on, you will do so with this line in a Rails application's +Gemfile+: + +<ruby> + gem 'blorgh', :path => "vendor/engines/blorgh" +</ruby> + +By specifying it as a gem within the +Gemfile+, Bundler will load it as such, parsing this +blorgh.gemspec+ file and requiring a file within the +lib+ directory called +lib/blorgh.rb+. This file requires the +blorgh/engine.rb+ file (located at +lib/blorgh/engine.rb+) and defines a base module called +Blorgh+. + +<ruby> +require "blorgh/engine" +module Blorgh +end +</ruby> -TODO: Describe here the process of generating an engine and what an engine comes with. +Within +lib/blorgh/engine.rb+ is the base class for the engine: + +<ruby> + TODO: lib/blorgh/engine.rb +</ruby> + +Within the +app/controllers+ directory there is a +blorgh+ directory and inside that a file called +application_controller.rb+. This file will provide any common functionality for the controllers of the engine. The +blorgh+ directory is where the other controllers for the engine will go. By placing them within this namespaced directory, you prevent them from possibly clashing with identically-named controllers within other engines or even within the application. h3. Providing engine functionality |