6
6
module Rails
7
7
# Railtie is the core of the Rails Framework and provides several hooks to extend
8
8
# Rails and/or modify the initialization process.
9
- #
9
+ #
10
10
# Every major component of Rails (Action Mailer, Action Controller,
11
11
# Action View, Active Record and Active Resource) are all Railties, so each of
12
12
# them is responsible to set their own initialization. This makes, for example,
13
13
# Rails absent of any Active Record hook, allowing any other ORM framework to hook in.
14
- #
14
+ #
15
15
# Developing a Rails extension does _not_ require any implementation of
16
16
# Railtie, but if you need to interact with the Rails framework during
17
17
# or after boot, then Railtie is what you need to do that interaction.
18
- #
18
+ #
19
19
# For example, the following would need you to implement Railtie in your
20
20
# plugin:
21
- #
21
+ #
22
22
# * creating initializers
23
23
# * configuring a Rails framework or the Application, like setting a generator
24
24
# * adding Rails config.* keys to the environment
25
25
# * setting up a subscriber to the Rails +ActiveSupport::Notifications+
26
26
# * adding rake tasks into rails
27
- #
27
+ #
28
28
# == Creating your Railtie
29
29
#
30
30
# Implementing Railtie in your Rails extension is done by creating a class
31
31
# Railtie that has your extension name and making sure that this gets loaded
32
32
# during boot time of the Rails stack.
33
- #
33
+ #
34
34
# You can do this however you wish, but here is an example if you want to provide
35
35
# it for a gem that can be used with or without Rails:
36
- #
36
+ #
37
37
# * Create a file (say, lib/my_gem/railtie.rb) which contains class Railtie inheriting from
38
38
# Rails::Railtie and is namespaced to your gem:
39
39
#
40
- # # lib/my_gem/railtie.rb
41
- # module MyGem
42
- # class Railtie < Rails::Railtie
40
+ # # lib/my_gem/railtie.rb
41
+ # module MyGem
42
+ # class Railtie < Rails::Railtie
43
+ # end
43
44
# end
44
- # end
45
- #
45
+ #
46
46
# * Require your own gem as well as rails in this file:
47
- #
48
- # # lib/my_gem/railtie.rb
49
- # require 'my_gem'
50
- # require 'rails'
51
- #
52
- # module MyGem
53
- # class Railtie < Rails::Railtie
47
+ #
48
+ # # lib/my_gem/railtie.rb
49
+ # require 'my_gem'
50
+ # require 'rails'
51
+ #
52
+ # module MyGem
53
+ # class Railtie < Rails::Railtie
54
+ # end
54
55
# end
55
- # end
56
56
#
57
57
# == Initializers
58
58
#
@@ -65,7 +65,7 @@ module Rails
65
65
# end
66
66
# end
67
67
#
68
- # If specified, the block can also receive the application object, in case you
68
+ # If specified, the block can also receive the application object, in case you
69
69
# need to access some application specific configuration, like middleware:
70
70
#
71
71
# class MyRailtie < Rails::Railtie
0 commit comments