-
Notifications
You must be signed in to change notification settings - Fork 0
/
rails3.txt
63 lines (51 loc) · 2.5 KB
/
rails3.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
= Modularity
== ActiveSupport
It is now viable to cherry-pick specific elements. All dependencies are explicit. Even better other parts of Rails now explicitly declare the dependencies they have on ActiveSupport. However, for simplicity, Rails 3 ships with all of ActiveSupport still provided. To turn it off, declare +config.active_support.bare = true+ in the configuration file (so, 3.days is not available any more unless the specific module is included).
== ActionController
It is splited into three parts:
* ActionDispatch: includes the dispatcher functionality.
* AbstractController: includes codes that were meant to be reused by non-HTTP controllers. Both ActionController and ActionMailer inherit from it.
* ActionController: the HTTP controller. Every standalone component has benn isolated, and it's possible to start with a stripped-down controller and pull in just the components that are needed. +ActionController::Base+ simply starts with that same stripped-down contrller and pulls everything in.
module ActionController
class Base < Metal
abstract!
include AbstractController::Callbacks
include AbstractController::Logger
include AbstractController::Helpers
...
end
end
Example of customizing controllers:
class FasterController < ActionController::Metal
abstract!
# Rendering would be pulled in by layouts, but I include it here for clarity
include ActionController::Rendering
include ActionController::Layouts
append_view_path Rails.root.join("app/views")
end
class AwesomeController < FasterController
def index; redner "so_speedy" end
end
# in routes
MyApp.routes.draw { match "/must_be_fast" => "awesome#index" }
+ActioinController::Middleware+, which is middleware with all of the powers of ActionController, allows you to pull in whatever ActionController features you want as needed. Example:
class MyMiddleware < ActionController::Middleware
include ActionController::ConditionalGet
include ...
def call(env)
...
end
end
= Performance
A few of the performance optimizations:
* Reducing general controller overhead
* (greatly) Speeding up rendering a collection of partials
* more!
= Plugin API
Even Rails 3 itself is trying to build itself on the core components. (Like ActionPack)
= ActiveModel
* Use ActiveModel::Lint to test a object if it's ActiveModel compliant.
* Two major elements:
* ActiveModel API
* ActiveModel Modules
.... TO BE CONTINUE! STAY TUNE!