railties 3.0.0.beta3 → 3.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/README +118 -123
- data/guides/source/3_0_release_notes.textile +13 -11
- data/guides/source/action_controller_overview.textile +2 -2
- data/guides/source/action_mailer_basics.textile +70 -26
- data/guides/source/action_view_overview.textile +1 -1
- data/guides/source/active_record_basics.textile +9 -1
- data/guides/source/active_record_querying.textile +2 -2
- data/guides/source/active_support_core_extensions.textile +377 -9
- data/guides/source/activerecord_validations_callbacks.textile +98 -55
- data/guides/source/association_basics.textile +1 -1
- data/guides/source/caching_with_rails.textile +1 -1
- data/guides/source/command_line.textile +23 -23
- data/guides/source/configuring.textile +1 -3
- data/guides/source/contribute.textile +27 -28
- data/guides/source/credits.html.erb +4 -4
- data/guides/source/debugging_rails_applications.textile +2 -2
- data/guides/source/form_helpers.textile +7 -6
- data/guides/source/generators.textile +19 -29
- data/guides/source/getting_started.textile +106 -49
- data/guides/source/i18n.textile +27 -27
- data/guides/source/index.html.erb +18 -8
- data/guides/source/initialization.textile +140 -514
- data/guides/source/layout.html.erb +6 -4
- data/guides/source/layouts_and_rendering.textile +5 -5
- data/guides/source/migrations.textile +7 -3
- data/guides/source/nested_model_forms.textile +2 -2
- data/guides/source/performance_testing.textile +11 -12
- data/guides/source/plugins.textile +30 -30
- data/guides/source/rails_application_templates.textile +3 -3
- data/guides/source/rails_on_rack.textile +3 -66
- data/guides/source/routing.textile +10 -4
- data/guides/source/security.textile +1 -1
- data/guides/source/testing.textile +55 -52
- data/guides/w3c_validator.rb +67 -0
- data/lib/rails.rb +1 -0
- data/lib/rails/application.rb +49 -13
- data/lib/rails/application/bootstrap.rb +7 -6
- data/lib/rails/application/configuration.rb +24 -47
- data/lib/rails/application/finisher.rb +8 -3
- data/lib/rails/backtrace_cleaner.rb +11 -12
- data/lib/rails/commands.rb +54 -54
- data/lib/rails/commands/application.rb +7 -2
- data/lib/rails/commands/{performance/benchmarker.rb → benchmarker.rb} +0 -0
- data/lib/rails/commands/dbconsole.rb +4 -3
- data/lib/rails/commands/destroy.rb +1 -0
- data/lib/rails/commands/generate.rb +1 -0
- data/lib/rails/commands/{performance/profiler.rb → profiler.rb} +0 -0
- data/lib/rails/commands/runner.rb +4 -2
- data/lib/rails/configuration.rb +36 -0
- data/lib/rails/engine.rb +24 -24
- data/lib/rails/engine/configuration.rb +0 -1
- data/lib/rails/generators.rb +48 -10
- data/lib/rails/generators/actions.rb +5 -3
- data/lib/rails/generators/base.rb +23 -17
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +9 -8
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb +1 -1
- data/lib/rails/generators/generated_attribute.rb +7 -6
- data/lib/rails/generators/rails/app/USAGE +2 -2
- data/lib/rails/generators/rails/app/app_generator.rb +242 -97
- data/lib/rails/generators/rails/app/templates/Gemfile +3 -0
- data/lib/rails/generators/rails/app/templates/README +167 -130
- data/lib/rails/generators/rails/app/templates/Rakefile +0 -3
- data/lib/rails/generators/rails/app/templates/config/boot.rb +9 -2
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +5 -5
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +4 -0
- data/lib/rails/generators/rails/app/templates/script/rails +2 -5
- data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +1 -3
- data/lib/rails/generators/rails/stylesheets/templates/scaffold.css +5 -9
- data/lib/rails/generators/test_case.rb +12 -0
- data/lib/rails/generators/test_unit/integration/templates/integration_test.rb +1 -1
- data/lib/rails/generators/test_unit/performance/templates/performance_test.rb +1 -1
- data/lib/rails/info.rb +0 -33
- data/lib/rails/log_subscriber.rb +13 -6
- data/lib/rails/rack/logger.rb +4 -3
- data/lib/rails/railtie.rb +4 -0
- data/lib/rails/railtie/configuration.rb +21 -4
- data/lib/rails/tasks/documentation.rake +2 -0
- data/lib/rails/tasks/framework.rake +22 -0
- data/lib/rails/tasks/middleware.rake +1 -1
- data/lib/rails/tasks/routes.rake +5 -1
- data/lib/rails/test_help.rb +3 -1
- data/lib/rails/test_unit/testing.rake +3 -1
- data/lib/rails/version.rb +1 -1
- metadata +12 -19
- data/lib/rails/application/metal_loader.rb +0 -50
- data/lib/rails/dispatcher.rb +0 -24
- data/lib/rails/generators/rails/mailer/USAGE +0 -15
- data/lib/rails/generators/rails/mailer/mailer_generator.rb +0 -14
- data/lib/rails/generators/rails/mailer/templates/mailer.rb +0 -16
- data/lib/rails/generators/rails/metal/USAGE +0 -8
- data/lib/rails/generators/rails/metal/metal_generator.rb +0 -11
- data/lib/rails/generators/rails/metal/templates/metal.rb +0 -12
data/CHANGELOG
CHANGED
data/README
CHANGED
@@ -3,12 +3,13 @@
|
|
3
3
|
Rails is a web-application framework that includes everything needed to create
|
4
4
|
database-backed web applications according to the Model-View-Control pattern.
|
5
5
|
|
6
|
-
This pattern splits the view (also called the presentation) into "dumb"
|
7
|
-
that are primarily responsible for inserting pre-built data in between
|
8
|
-
The model contains the "smart" domain objects (such as Account,
|
9
|
-
Post) that holds all the business logic and knows how to
|
10
|
-
a database. The controller handles the incoming requests
|
11
|
-
Update Product, Show Post) by manipulating the model
|
6
|
+
This pattern splits the view (also called the presentation) into "dumb"
|
7
|
+
templates that are primarily responsible for inserting pre-built data in between
|
8
|
+
HTML tags. The model contains the "smart" domain objects (such as Account,
|
9
|
+
Product, Person, Post) that holds all the business logic and knows how to
|
10
|
+
persist themselves to a database. The controller handles the incoming requests
|
11
|
+
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
12
|
+
and directing data to the view.
|
12
13
|
|
13
14
|
In Rails, the model is handled by what's called an object-relational mapping
|
14
15
|
layer entitled Active Record. This layer allows you to present the data from
|
@@ -21,88 +22,65 @@ layers by its two parts: Action View and Action Controller. These two layers
|
|
21
22
|
are bundled in a single package due to their heavy interdependence. This is
|
22
23
|
unlike the relationship between the Active Record and Action Pack that is much
|
23
24
|
more separate. Each of these packages can be used independently outside of
|
24
|
-
Rails.
|
25
|
+
Rails. You can read more about Action Pack in
|
25
26
|
link:files/vendor/rails/actionpack/README.html.
|
26
27
|
|
27
28
|
|
28
29
|
== Getting Started
|
29
30
|
|
30
|
-
1. At the command prompt,
|
31
|
-
|
32
|
-
2. Change directory into myapp and start the web server: <tt>rails server</tt> (run with --help for options)
|
33
|
-
3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
|
34
|
-
4. Follow the guidelines to start developing your application
|
31
|
+
1. At the command prompt, create a new Rails application:
|
32
|
+
<tt>rails myapp</tt> (where <tt>myapp</tt> is the application name)
|
35
33
|
|
34
|
+
2. Change directory to <tt>myapp</tt> and start the web server:
|
35
|
+
<tt>cd myapp; rails server</tt> (run with --help for options)
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
By default, Rails will try to use Mongrel if it's installed when started with <tt>rails server</tt>, otherwise
|
40
|
-
Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails with a variety of
|
41
|
-
other web servers.
|
42
|
-
|
43
|
-
Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
|
44
|
-
suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
|
45
|
-
getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
|
46
|
-
More info at: http://mongrel.rubyforge.org
|
47
|
-
|
48
|
-
Other ruby web servers exist which can run your rails application, however <tt>rails server</tt> does
|
49
|
-
not search for them or start them. These include {Thin}[http://code.macournoyer.com/thin/], {Ebb}[http://ebb.rubyforge.org/], and Apache with {mod_rails}[http://www.modrails.com/].
|
50
|
-
|
51
|
-
For production use, often a web/proxy server such as {Apache}[http://apache.org], {Nginx}[http://nginx.net/], {LiteSpeed}[http://litespeedtech.com/], {Lighttpd}[http://www.lighttpd.net/] or {IIS}[http://www.iis.net/] is
|
52
|
-
deployed as the front-end server, with the chosen ruby web server running in the back-end
|
53
|
-
and receiving the proxied requests via one of several protocols (HTTP, CGI, FCGI).
|
54
|
-
|
37
|
+
3. Go to http://localhost:3000/ and you'll see:
|
38
|
+
"Welcome aboard: You're riding the Rails!"
|
55
39
|
|
56
|
-
|
40
|
+
4. Follow the guidelines to start developing your application. You can find
|
41
|
+
the following resources handy:
|
57
42
|
|
58
|
-
|
43
|
+
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
44
|
+
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
59
45
|
|
60
|
-
AddHandler fastcgi-script .fcgi
|
61
|
-
AddHandler cgi-script .cgi
|
62
|
-
Options +FollowSymLinks +ExecCGI
|
63
46
|
|
64
|
-
|
65
|
-
rewrite rules so that Apache won't rewrite certain requests.
|
66
|
-
|
67
|
-
RewriteCond %{REQUEST_URI} ^/notrails.*
|
68
|
-
RewriteRule .* - [L]
|
69
|
-
|
70
|
-
Redirect all requests not available on the filesystem to Rails. By default the
|
71
|
-
cgi dispatcher is used which is very slow, for better performance replace the
|
72
|
-
dispatcher with the fastcgi one.
|
47
|
+
== Web Servers
|
73
48
|
|
74
|
-
|
75
|
-
|
49
|
+
By default, Rails will try to use Mongrel if it's installed when started with
|
50
|
+
<tt>rails server</tt>, otherwise Rails will use WEBrick, the web server that
|
51
|
+
ships with Ruby.
|
76
52
|
|
77
|
-
|
78
|
-
|
53
|
+
Mongrel is a Ruby-based web server with a C component (which requires
|
54
|
+
compilation) that is suitable for development. If you have Ruby Gems installed,
|
55
|
+
getting up and running with mongrel is as easy as:
|
56
|
+
<tt>sudo gem install mongrel</tt>.
|
79
57
|
|
80
|
-
|
81
|
-
RewriteBase /myrailsapp
|
58
|
+
You can find more info at: http://mongrel.rubyforge.org
|
82
59
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
60
|
+
You can alternatively run Rails applications with other Ruby web servers, e.g.,
|
61
|
+
{Thin}[http://code.macournoyer.com/thin/], {Ebb}[http://ebb.rubyforge.org/], and
|
62
|
+
Apache with {mod_rails}[http://www.modrails.com/]. However, <tt>rails server</tt>
|
63
|
+
doesn't search for or start them.
|
87
64
|
|
88
|
-
|
89
|
-
|
65
|
+
For production use, often a web/proxy server, e.g., {Apache}[http://apache.org],
|
66
|
+
{Nginx}[http://nginx.net/], {LiteSpeed}[http://litespeedtech.com/],
|
67
|
+
{Lighttpd}[http://www.lighttpd.net/], or {IIS}[http://www.iis.net/], is deployed
|
68
|
+
as the front end server with the chosen Ruby web server running in the back end
|
69
|
+
and receiving the proxied requests via one of several protocols (HTTP, CGI, FCGI).
|
90
70
|
|
91
|
-
ErrorDocument 500 /500.html
|
92
|
-
ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
|
93
71
|
|
94
72
|
== Debugging Rails
|
95
73
|
|
96
|
-
Sometimes your application goes wrong.
|
74
|
+
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
97
75
|
will help you debug it and get it back on the rails.
|
98
76
|
|
99
|
-
First area to check is the application log files.
|
100
|
-
on the server.log and development.log. Rails will automatically display
|
101
|
-
and runtime information to these files. Debugging info will also be
|
102
|
-
browser on requests from 127.0.0.1.
|
77
|
+
First area to check is the application log files. Have "tail -f" commands
|
78
|
+
running on the server.log and development.log. Rails will automatically display
|
79
|
+
debugging and runtime information to these files. Debugging info will also be
|
80
|
+
shown in the browser on requests from 127.0.0.1.
|
103
81
|
|
104
|
-
You can also log your own messages directly into the log file from your code
|
105
|
-
the Ruby logger class from inside your controllers. Example:
|
82
|
+
You can also log your own messages directly into the log file from your code
|
83
|
+
using the Ruby logger class from inside your controllers. Example:
|
106
84
|
|
107
85
|
class WeblogController < ActionController::Base
|
108
86
|
def destroy
|
@@ -114,26 +92,27 @@ the Ruby logger class from inside your controllers. Example:
|
|
114
92
|
|
115
93
|
The result will be a message in your log file along the lines of:
|
116
94
|
|
117
|
-
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
|
95
|
+
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
118
96
|
|
119
97
|
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
120
98
|
|
121
|
-
Also, Ruby documentation can be found at http://www.ruby-lang.org
|
99
|
+
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
100
|
+
several books available online as well:
|
122
101
|
|
123
|
-
*
|
124
|
-
* Learn to Program: http://pine.fm/LearnToProgram/
|
102
|
+
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
103
|
+
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
125
104
|
|
126
|
-
These two
|
127
|
-
|
105
|
+
These two books will bring you up to speed on the Ruby language and also on
|
106
|
+
programming in general.
|
128
107
|
|
129
108
|
|
130
109
|
== Debugger
|
131
110
|
|
132
|
-
Debugger support is available through the debugger command when you start your
|
133
|
-
|
134
|
-
in the code, investigate and change the model,
|
135
|
-
You need to install ruby-debug to run the server in debugging
|
136
|
-
Example:
|
111
|
+
Debugger support is available through the debugger command when you start your
|
112
|
+
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
113
|
+
execution at any point in the code, investigate and change the model, and then,
|
114
|
+
resume execution! You need to install ruby-debug to run the server in debugging
|
115
|
+
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
137
116
|
|
138
117
|
class WeblogController < ActionController::Base
|
139
118
|
def index
|
@@ -146,49 +125,60 @@ So the controller will accept the action, run the first line, then present you
|
|
146
125
|
with a IRB prompt in the server window. Here you can do things like:
|
147
126
|
|
148
127
|
>> @posts.inspect
|
149
|
-
=> "[#<Post:0x14a6be8
|
150
|
-
|
128
|
+
=> "[#<Post:0x14a6be8
|
129
|
+
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
130
|
+
#<Post:0x14a6620
|
131
|
+
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
151
132
|
>> @posts.first.title = "hello from a debugger"
|
152
133
|
=> "hello from a debugger"
|
153
134
|
|
154
|
-
...and even better
|
135
|
+
...and even better, you can examine how your runtime objects actually work:
|
155
136
|
|
156
137
|
>> f = @posts.first
|
157
138
|
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
158
139
|
>> f.
|
159
140
|
Display all 152 possibilities? (y or n)
|
160
141
|
|
161
|
-
Finally, when you're ready to resume execution, you enter "cont"
|
142
|
+
Finally, when you're ready to resume execution, you can enter "cont".
|
162
143
|
|
163
144
|
|
164
145
|
== Console
|
165
146
|
|
166
|
-
The console is a
|
167
|
-
model. Here you'll have all parts of the application
|
168
|
-
application is running. You can inspect
|
169
|
-
|
147
|
+
The console is a Ruby shell, which allows you to interact with your
|
148
|
+
application's domain model. Here you'll have all parts of the application
|
149
|
+
configured, just like it is when the application is running. You can inspect
|
150
|
+
domain models, change values, and save to the database. Starting the script
|
151
|
+
without arguments will launch it in the development environment.
|
170
152
|
|
171
|
-
To start the console,
|
153
|
+
To start the console, run <tt>rails console</tt> from the application
|
154
|
+
directory.
|
172
155
|
|
173
156
|
Options:
|
174
157
|
|
175
|
-
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
176
|
-
|
177
|
-
|
158
|
+
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
159
|
+
made to the database.
|
160
|
+
* Passing an environment name as an argument will load the corresponding
|
161
|
+
environment. Example: <tt>rails console production</tt>.
|
162
|
+
|
163
|
+
To reload your controllers and models after launching the console run
|
164
|
+
<tt>reload!</tt>
|
165
|
+
|
166
|
+
More information about irb can be found at:
|
167
|
+
link:http://www.rubycentral.com/pickaxe/irb.html
|
178
168
|
|
179
|
-
More information about irb can be found at link:http://www.rubycentral.com/pickaxe/irb.html
|
180
169
|
|
181
170
|
== dbconsole
|
182
171
|
|
183
|
-
You can go to the command line of your database directly through <tt>rails
|
184
|
-
You would be connected to the database with the credentials
|
185
|
-
Starting the script without arguments will connect you
|
186
|
-
argument will connect you to a different
|
187
|
-
Currently works for
|
172
|
+
You can go to the command line of your database directly through <tt>rails
|
173
|
+
dbconsole</tt>. You would be connected to the database with the credentials
|
174
|
+
defined in database.yml. Starting the script without arguments will connect you
|
175
|
+
to the development database. Passing an argument will connect you to a different
|
176
|
+
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
177
|
+
PostgreSQL and SQLite 3.
|
188
178
|
|
189
179
|
== Description of Contents
|
190
180
|
|
191
|
-
The default directory structure of a generated Ruby on Rails
|
181
|
+
The default directory structure of a generated Ruby on Rails application:
|
192
182
|
|
193
183
|
|-- app
|
194
184
|
| |-- controllers
|
@@ -230,57 +220,62 @@ app
|
|
230
220
|
|
231
221
|
app/controllers
|
232
222
|
Holds controllers that should be named like weblogs_controller.rb for
|
233
|
-
automated URL mapping. All controllers should descend from
|
234
|
-
which itself descends from ActionController::Base.
|
223
|
+
automated URL mapping. All controllers should descend from
|
224
|
+
ApplicationController which itself descends from ActionController::Base.
|
235
225
|
|
236
226
|
app/models
|
237
|
-
Holds models that should be named like post.rb.
|
238
|
-
|
227
|
+
Holds models that should be named like post.rb. Models descend from
|
228
|
+
ActiveRecord::Base by default.
|
239
229
|
|
240
230
|
app/views
|
241
231
|
Holds the template files for the view that should be named like
|
242
|
-
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
243
|
-
syntax.
|
232
|
+
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
233
|
+
eRuby syntax by default.
|
244
234
|
|
245
235
|
app/views/layouts
|
246
|
-
Holds the template files for layouts to be used with views. This models the
|
247
|
-
header/footer method of wrapping views. In your views, define a layout
|
248
|
-
<tt>layout :default</tt> and create a file named default.html.erb.
|
249
|
-
call <% yield %> to render the view using this
|
236
|
+
Holds the template files for layouts to be used with views. This models the
|
237
|
+
common header/footer method of wrapping views. In your views, define a layout
|
238
|
+
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
239
|
+
Inside default.html.erb, call <% yield %> to render the view using this
|
240
|
+
layout.
|
250
241
|
|
251
242
|
app/helpers
|
252
|
-
Holds view helpers that should be named like weblogs_helper.rb. These are
|
253
|
-
for you automatically when using
|
254
|
-
wrap functionality for your views into methods.
|
243
|
+
Holds view helpers that should be named like weblogs_helper.rb. These are
|
244
|
+
generated for you automatically when using generators for controllers.
|
245
|
+
Helpers can be used to wrap functionality for your views into methods.
|
255
246
|
|
256
247
|
config
|
257
|
-
Configuration files for the Rails environment, the routing map, the database,
|
248
|
+
Configuration files for the Rails environment, the routing map, the database,
|
249
|
+
and other dependencies.
|
258
250
|
|
259
251
|
db
|
260
|
-
Contains the database schema in schema.rb.
|
261
|
-
|
252
|
+
Contains the database schema in schema.rb. db/migrate contains all the
|
253
|
+
sequence of Migrations for your schema.
|
262
254
|
|
263
255
|
doc
|
264
|
-
This directory is where your application documentation will be stored when
|
265
|
-
using <tt>rake doc:app</tt>
|
256
|
+
This directory is where your application documentation will be stored when
|
257
|
+
generated using <tt>rake doc:app</tt>
|
266
258
|
|
267
259
|
lib
|
268
|
-
Application specific libraries. Basically, any kind of custom code that
|
269
|
-
belong under controllers, models, or helpers. This directory is in
|
260
|
+
Application specific libraries. Basically, any kind of custom code that
|
261
|
+
doesn't belong under controllers, models, or helpers. This directory is in
|
262
|
+
the load path.
|
270
263
|
|
271
264
|
public
|
272
|
-
The directory available for the web server. Contains subdirectories for
|
273
|
-
and javascripts. Also contains the dispatchers and the
|
274
|
-
set as the DOCUMENT_ROOT of your web
|
265
|
+
The directory available for the web server. Contains subdirectories for
|
266
|
+
images, stylesheets, and javascripts. Also contains the dispatchers and the
|
267
|
+
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
268
|
+
server.
|
275
269
|
|
276
270
|
script
|
277
271
|
Helper scripts for automation and generation.
|
278
272
|
|
279
273
|
test
|
280
|
-
Unit and functional tests along with fixtures. When using the
|
281
|
-
test files will be generated for you and placed in this
|
274
|
+
Unit and functional tests along with fixtures. When using the rails generate
|
275
|
+
command, template test files will be generated for you and placed in this
|
276
|
+
directory.
|
282
277
|
|
283
278
|
vendor
|
284
|
-
External libraries that the application depends on. Also includes the plugins
|
285
|
-
If the app has frozen rails, those gems also go here, under
|
286
|
-
This directory is in the load path.
|
279
|
+
External libraries that the application depends on. Also includes the plugins
|
280
|
+
subdirectory. If the app has frozen rails, those gems also go here, under
|
281
|
+
vendor/rails/. This directory is in the load path.
|
@@ -20,14 +20,10 @@ endprologue.
|
|
20
20
|
|
21
21
|
WARNING: Rails 3.0 is currently in beta. This means that there are probably bugs and that you should "report them":http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/overview if you see them. You also may not want to run the NORAD nuclear launch application off a beta version. But if you're starting development on a new application and you don't mind getting wind in your hair, please do jump on board!
|
22
22
|
|
23
|
-
|
23
|
+
To install the last Rails 3 beta:
|
24
24
|
|
25
25
|
<shell>
|
26
26
|
# Use sudo if your setup requires it
|
27
|
-
gem install tzinfo builder i18n memcache-client rack \
|
28
|
-
rake rack-test erubis mail text-format \
|
29
|
-
thor bundler
|
30
|
-
gem install rack-mount -v=0.4
|
31
27
|
gem install rails --pre
|
32
28
|
</shell>
|
33
29
|
|
@@ -40,6 +36,8 @@ h4. Rails 3 requires Ruby 1.8.7+
|
|
40
36
|
|
41
37
|
Rails 3.0 requires Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially and you should upgrade as early as possible. Rails 3.0 is also compatible with Ruby 1.9.2.
|
42
38
|
|
39
|
+
TIP: Note that Ruby 1.8.7 p248 and p249 has marshaling bugs that crash Rails 3.0.0. Ruby Enterprise Edition have these fixed since release 1.8.7-2010.02 though. On the 1.9 front, Ruby 1.9.1 is not usable because it outright segfaults on Rails 3.0.0, so if you want to use Rails 3 with 1.9.x jump on 1.9.2 for smooth sailing.
|
40
|
+
|
43
41
|
h4. Rails Application object
|
44
42
|
|
45
43
|
As part of the groundwork for supporting running multiple Rails applications in the same process, Rails 3 introduces the concept of an Application object. An application object holds all the application specific configurations and is very similar in nature to +config/environment.rb+ from the previous versions of Rails.
|
@@ -83,7 +81,7 @@ The new installing rails sequence (for the beta) is:
|
|
83
81
|
|
84
82
|
<shell>
|
85
83
|
$ gem install rails --prerelease
|
86
|
-
$ rails myapp
|
84
|
+
$ rails new myapp
|
87
85
|
$ cd myapp
|
88
86
|
</shell>
|
89
87
|
|
@@ -91,7 +89,7 @@ h4. Vendoring Gems
|
|
91
89
|
|
92
90
|
Rails now uses a +Gemfile+ in the application root to determine the gems you require for your application to start. This +Gemfile+ is processed by the "Bundler":http://github.com/carlhuda/bundler, which then installs all your dependencies. It can even install all the dependencies locally to your application so that it doesn't depend on the system gems.
|
93
91
|
|
94
|
-
More information: - "bundler
|
92
|
+
More information: - "bundler homepage":http://gembundler.com
|
95
93
|
|
96
94
|
h4. Living on the Edge
|
97
95
|
|
@@ -100,13 +98,13 @@ h4. Living on the Edge
|
|
100
98
|
If you want to bundle straight from the Git repository, you can pass the +--edge+ flag:
|
101
99
|
|
102
100
|
<shell>
|
103
|
-
$ rails myapp --edge
|
101
|
+
$ rails new myapp --edge
|
104
102
|
</shell>
|
105
103
|
|
106
104
|
If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the +--dev+ flag:
|
107
105
|
|
108
106
|
<shell>
|
109
|
-
$ ruby /path/to/rails/
|
107
|
+
$ ruby /path/to/rails/bin/rails new myapp --dev
|
110
108
|
</shell>
|
111
109
|
|
112
110
|
h3. Rails Architectural Changes
|
@@ -187,7 +185,7 @@ Railties generators got a huge amount of attention in Rails 3.0, basically:
|
|
187
185
|
* Rails templates API and generators API were merged (they are the same as the former).
|
188
186
|
* Generators are no longer loaded from special paths anymore, they are just found in the Ruby load path, so calling <tt>rails generate foo</tt> will look for <tt>generators/foo_generator</tt>.
|
189
187
|
* New generators provide hooks, so any template engine, ORM, test framework can easily hook in.
|
190
|
-
* New generators allow you to override the templates by placing a copy at <tt>
|
188
|
+
* New generators allow you to override the templates by placing a copy at <tt>Rails.root/lib/templates</tt>.
|
191
189
|
* <tt>Rails::Generators::TestCase</tt> is also supplied so you can create your own generators and test them.
|
192
190
|
|
193
191
|
Also, the views generated by Railties generators had some overhaul:
|
@@ -277,7 +275,7 @@ end
|
|
277
275
|
|
278
276
|
<ruby>
|
279
277
|
scope 'es' do
|
280
|
-
resources :projects, :path_names => { :edit => 'cambiar' }, :
|
278
|
+
resources :projects, :path_names => { :edit => 'cambiar' }, :path => 'projeto'
|
281
279
|
end
|
282
280
|
|
283
281
|
# Gives you the edit action with /es/projeto/1/cambiar
|
@@ -514,6 +512,7 @@ These are the main changes in Active Support:
|
|
514
512
|
* Active Support no longer provides vendored versions of "TZInfo":http://tzinfo.rubyforge.org/, "Memcache Client":http://deveiate.org/projects/RMemCache/ and "Builder":http://builder.rubyforge.org/, these are all included as dependencies and installed via the <tt>bundle install</tt> command.
|
515
513
|
* Safe buffers are implemented in <tt>ActiveSupport::SafeBuffer</tt>.
|
516
514
|
* Added <tt>Array.uniq_by</tt> and <tt>Array.uniq_by!</tt>.
|
515
|
+
* Removed <tt>Array#rand</tt> and backported <tt>Array#sample</tt> from Ruby 1.9.
|
517
516
|
* Fixed bug on +TimeZone.seconds_to_utc_offset+ returning wrong value.
|
518
517
|
* Added <tt>ActiveSupport::Notifications</tt> middleware.
|
519
518
|
* <tt>ActiveSupport.use_standard_json_time_format</tt> now defaults to true.
|
@@ -566,12 +565,15 @@ Action Mailer has been given a new API with TMail being replaced out with the ne
|
|
566
565
|
|
567
566
|
* All mailers are now in <tt>app/mailers</tt> by default.
|
568
567
|
* Can now send email using new API with three methods: +attachments+, +headers+ and +mail+.
|
568
|
+
* ActionMailer now has native support for inline attachments using the <tt>attachments.inline</tt> method.
|
569
569
|
* Action Mailer emailing methods now return <tt>Mail::Message</tt> objects, which can then be sent the +deliver+ message to send itself.
|
570
570
|
* All delivery methods are now abstracted out to the Mail gem.
|
571
571
|
* The mail delivery method can accept a hash of all valid mail header fields with their value pair.
|
572
572
|
* The +mail+ delivery method acts in a similar way to Action Controller's +respond_to+, and you can explicitly or implicitly render templates. Action Mailer will turn the email into a multipart email as needed.
|
573
573
|
* You can pass a proc to the <tt>format.mime_type</tt> calls within the mail block and explicitly render specific types of text, or add layouts or different templates. The +render+ call inside the proc is from Abstract Controller and supports the same options.
|
574
574
|
* What were mailer unit tests have been moved to functional tests.
|
575
|
+
* Action Mailer now delegates all auto encoding of header fields and bodies to Mail Gem
|
576
|
+
* Action Mailer will auto encode email bodies and headers for you
|
575
577
|
|
576
578
|
Deprecations:
|
577
579
|
|