aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_controller/base.rb4
-rw-r--r--actionpack/lib/action_view/base.rb2
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb10
-rw-r--r--actionpack/lib/action_view/helpers/javascript_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb8
-rw-r--r--activemodel/lib/active_model/validator.rb4
-rw-r--r--activeresource/test/cases/base/schema_test.rb2
-rw-r--r--railties/guides/source/action_controller_overview.textile2
-rw-r--r--railties/guides/source/action_view_overview.textile2
-rw-r--r--railties/guides/source/caching_with_rails.textile2
-rw-r--r--railties/guides/source/configuring.textile2
-rw-r--r--railties/guides/source/form_helpers.textile8
-rw-r--r--railties/guides/source/plugins.textile82
-rw-r--r--railties/guides/source/routing.textile12
14 files changed, 74 insertions, 68 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 631a0f2945..48308cbb60 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -93,9 +93,9 @@ module ActionController
# * ActiveRecord::SessionStore - Sessions are stored in your database, which works better than PStore with multiple app servers and,
# unlike CookieStore, hides your session contents from the user. To use ActiveRecord::SessionStore, set
#
- # config.action_controller.session_store = :active_record_store
+ # MyApplication::Application.config.session_store :active_record_store
#
- # in your <tt>config/environment.rb</tt> and run <tt>rake db:sessions:create</tt>.
+ # in your <tt>config/initializers/session_store.rb</tt> and run <tt>script/rails g session_migration</tt>.
#
# == Responses
#
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index b0a57f47d3..3fa46d0f43 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -153,7 +153,7 @@ module ActionView #:nodoc:
#
# This refreshes the sidebar, removes a person element and highlights the user list.
#
- # See the ActionView::Helpers::PrototypeHelper::GeneratorMethods documentation for more details.
+ # See the ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods documentation for more details.
class Base
module Subclasses
end
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 6ca956f879..0937075edf 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -211,7 +211,7 @@ module ActionView
# If you have an object that needs to be represented as a different
# parameter, like a Client that acts as a Person:
#
- # <%= form_for(@post, :as => :client do |f| %>
+ # <%= form_for(@post, :as => :client) do |f| %>
# ...
# <% end %>
#
@@ -228,8 +228,8 @@ module ActionView
# ...
# <% end %>
#
- # Where +@document = Document.find(params[:id])+ and
- # +@comment = Comment.new+.
+ # Where <tt>@document = Document.find(params[:id])</tt> and
+ # <tt>@comment = Comment.new</tt>.
#
# === Unobtrusive JavaScript
#
@@ -656,11 +656,13 @@ module ActionView
InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("hidden", options)
end
- # Returns an file upload input tag tailored for accessing a specified attribute (identified by +method+) on an object
+ # Returns a file upload input tag tailored for accessing a specified attribute (identified by +method+) on an object
# assigned to the template (identified by +object+). Additional options on the input tag can be passed as a
# hash with +options+. These options will be tagged onto the HTML as an HTML element attribute as in the example
# shown.
#
+ # Using this method inside a +form_for+ block will set the enclosing form's encoding to <tt>multipart/form-data</tt>.
+ #
# ==== Examples
# file_field(:user, :avatar)
# # => <input type="file" id="user_avatar" name="user[avatar]" />
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb
index f392d92e75..cd3a3eac80 100644
--- a/actionpack/lib/action_view/helpers/javascript_helper.rb
+++ b/actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -65,7 +65,7 @@ module ActionView
# //]]>
# </script>
#
- # +html_options+ may be a hash of attributes for the <tt><script></tt>
+ # +html_options+ may be a hash of attributes for the <tt>\<script></tt>
# tag. Example:
# javascript_tag "alert('All is good')", :defer => 'defer'
# # => <script defer="defer" type="text/javascript">alert('All is good')</script>
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index bc67197e64..300207dfac 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -161,7 +161,7 @@ module ActionView
# JavaScriptGenerator generates blocks of JavaScript code that allow you
# to change the content and presentation of multiple DOM elements. Use
- # this in your Ajax response bodies, either in a <tt><script></tt> tag
+ # this in your Ajax response bodies, either in a <tt>\<script></tt> tag
# or as plain JavaScript sent with a Content-type of "text/javascript".
#
# Create new instances with PrototypeHelper#update_page or with
@@ -224,7 +224,7 @@ module ActionView
#
# You can also use PrototypeHelper#update_page_tag instead of
# PrototypeHelper#update_page to wrap the generated JavaScript in a
- # <tt><script></tt> tag.
+ # <tt>\<script></tt> tag.
module GeneratorMethods
def to_s #:nodoc:
(@lines * $/).tap do |javascript|
@@ -583,10 +583,10 @@ module ActionView
end
# Works like update_page but wraps the generated JavaScript in a
- # <tt><script></tt> tag. Use this to include generated JavaScript in an
+ # <tt>\<script></tt> tag. Use this to include generated JavaScript in an
# ERb template. See JavaScriptGenerator for more information.
#
- # +html_options+ may be a hash of <tt><script></tt> attributes to be
+ # +html_options+ may be a hash of <tt>\<script></tt> attributes to be
# passed to ActionView::Helpers::JavaScriptHelper#javascript_tag.
def update_page_tag(html_options = {}, &block)
javascript_tag update_page(&block), html_options
diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb
index 1262d305d1..0168233fce 100644
--- a/activemodel/lib/active_model/validator.rb
+++ b/activemodel/lib/active_model/validator.rb
@@ -7,7 +7,7 @@ module ActiveModel #:nodoc:
# == Active Model Validator
#
# A simple base class that can be used along with
- # +ActiveModel::Validations::ClassMethods.validates_with+
+ # ActiveModel::Validations::ClassMethods.validates_with
#
# class Person
# include ActiveModel::Validations
@@ -42,7 +42,7 @@ module ActiveModel #:nodoc:
# end
# end
#
- # To cause a validation error, you must add to the <tt>record<tt>'s errors directly
+ # To cause a validation error, you must add to the <tt>record</tt>'s errors directly
# from within the validators message
#
# class MyValidator < ActiveModel::Validator
diff --git a/activeresource/test/cases/base/schema_test.rb b/activeresource/test/cases/base/schema_test.rb
index be9807e5c8..37f30e4353 100644
--- a/activeresource/test/cases/base/schema_test.rb
+++ b/activeresource/test/cases/base/schema_test.rb
@@ -386,7 +386,7 @@ class SchemaTest < ActiveModel::TestCase
assert_not_equal matz.known_attributes, rick.known_attributes, "should have had different known attributes too"
end
- test "setting schema then fetching should add schema attributes to the intance attributes" do
+ test "setting schema then fetching should add schema attributes to the instance attributes" do
# an attribute in common with fetched instance and one that isn't
new_schema = {'age' => 'integer', 'name' => 'string',
'height' => 'float', 'bio' => 'text',
diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile
index b38ae07043..5c77d74df1 100644
--- a/railties/guides/source/action_controller_overview.textile
+++ b/railties/guides/source/action_controller_overview.textile
@@ -161,7 +161,7 @@ If you need a different session storage mechanism, you can change it in the +con
<ruby>
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
-# (create the session table with "rake db:sessions:create")
+# (create the session table with "script/rails g session_migration")
# YourApp::Application.config.session_store :active_record_store
</ruby>
diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile
index 459d70f111..843dfe530d 100644
--- a/railties/guides/source/action_view_overview.textile
+++ b/railties/guides/source/action_view_overview.textile
@@ -654,7 +654,7 @@ The core method of this helper, form_for, gives you the ability to create a form
<ruby>
# Note: a @person variable will have been created in the controller (e.g. @person = Person.new)
-<%= form_for :person, @person, :url => { :action => "create" } do |f| %>
+<%= form_for @person, :url => { :action => "create" } do |f| %>
<%= f.text_field :first_name %>
<%= f.text_field :last_name %>
<%= submit_tag 'Create' %>
diff --git a/railties/guides/source/caching_with_rails.textile b/railties/guides/source/caching_with_rails.textile
index 818c6eb00e..09cd796271 100644
--- a/railties/guides/source/caching_with_rails.textile
+++ b/railties/guides/source/caching_with_rails.textile
@@ -367,7 +367,7 @@ h3. Advanced Caching
Along with the built-in mechanisms outlined above, a number of excellent plugins exist to help with finer grained control over caching. These include Chris Wanstrath's excellent cache_fu plugin (more info "here":http://errtheblog.com/posts/57-kickin-ass-w-cachefu ) and Evan Weaver's interlock plugin (more info "here":http://blog.evanweaver.com/articles/2007/12/13/better-rails-caching/ ). Both of these plugins play nice with memcached and are a must-see for anyone
seriously considering optimizing their caching needs.
-Also the new "Cache money":http://github.com/nkallen/cache-money/tree/master plugin is supposed to be mad cool.
+Also the new "Cache money":http://github.com/ngmoco/cache-money/tree/rails3 plugin is supposed to be mad cool.
h3. References
diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile
index 6a4f411acc..bb38c64307 100644
--- a/railties/guides/source/configuring.textile
+++ b/railties/guides/source/configuring.textile
@@ -149,8 +149,6 @@ WARNING: Threadsafe operation is incompatible with the normal workings of develo
* +config.action_controller.optimise_named_routes+ turns on some optimizations in generating the routing table. It is set to +true+ by default.
-* +config.action_controller.use_accept_header+ sets the rules for determining the response format. If this is set to +true+ (the default) then +respond_to+ and +Request#format+ will take the Accept header into account. If it is set to false then the request format will be determined solely by examining +params[:format]+. If there is no +format+ parameter, then the response format will be either HTML or Javascript depending on whether the request is an AJAX request.
-
* +config.action_controller.allow_forgery_protection+ enables or disables CSRF protection. By default this is +false+ in test mode and +true+ in all other modes.
* +config.action_controller.relative_url_root+ can be used to tell Rails that you are deploying to a subdirectory. The default is +ENV['RAILS_RELATIVE_URL_ROOT']+.
diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile
index eb2bbc4ee9..e3b9d745b2 100644
--- a/railties/guides/source/form_helpers.textile
+++ b/railties/guides/source/form_helpers.textile
@@ -222,7 +222,7 @@ end
The corresponding view +app/views/articles/new.html.erb+ using +form_for+ looks like this:
<erb>
-<%= form_for :article, @article, :url => { :action => "create" }, :html => {:class => "nifty_form"} do |f| %>
+<%= form_for @article, :url => { :action => "create" }, :html => {:class => "nifty_form"} do |f| %>
<%= f.text_field :title %>
<%= f.text_area :body, :size => "60x12" %>
<%= submit_tag "Create" %>
@@ -253,7 +253,7 @@ The helper methods called on the form builder are identical to the model object
You can create a similar binding without actually creating +&lt;form&gt;+ tags with the +fields_for+ helper. This is useful for editing additional model objects with the same form. For example if you had a Person model with an associated ContactDetail model you could create a form for creating both like so:
<erb>
-<%= form_for :person, @person, :url => { :action => "create" } do |person_form| %>
+<%= form_for @person, :url => { :action => "create" } do |person_form| %>
<%= person_form.text_field :name %>
<%= fields_for @person.contact_detail do |contact_details_form| %>
<%= contact_details_form.text_field :phone_number %>
@@ -549,7 +549,7 @@ will produce the same output if the current year is 2009 and the value chosen by
h3. Uploading Files
-A common task is uploading some sort of file, whether it's a picture of a person or a CSV file containing data to process. The most important thing to remember with file uploads is that the form's encoding *MUST* be set to "multipart/form-data". If you're using +form_for+ just using +file_field+ inside of it does the trick, but if you're using +form_tag+ +:multi_part => true+ must passed as an HTML option, in the second options hash. If you forget to do this the file will not be uploaded.
+A common task is uploading some sort of file, whether it's a picture of a person or a CSV file containing data to process. The most important thing to remember with file uploads is that the rendered form's encoding *MUST* be set to "multipart/form-data". If you use +form_for+, this is done automatically. If you use +form_tag+, you must set it yourself, as per the following example.
The following two forms both upload a file.
@@ -563,6 +563,8 @@ The following two forms both upload a file.
<% end %>
</erb>
+NOTE: Since Rails 3.1, forms rendered using +form_for+ have their encoding set to <tt>multipart/form-data</tt> automatically once a +file_field+ is used inside the block. Previous versions required you to set this explicitly.
+
Rails provides the usual pair of helpers: the barebones +file_field_tag+ and the model oriented +file_field+. The only difference with other helpers is that you cannot set a default value for file inputs as this would have no meaning. As you would expect in the first case the uploaded file is in +params[:picture]+ and in the second case in +params[:person][:picture]+.
h4. What Gets Uploaded
diff --git a/railties/guides/source/plugins.textile b/railties/guides/source/plugins.textile
index 677a8a3667..c04c7b9406 100644
--- a/railties/guides/source/plugins.textile
+++ b/railties/guides/source/plugins.textile
@@ -39,6 +39,7 @@ The examples in this guide require that you have a working rails application. T
gem install rails
rails new yaffle_guide
cd yaffle_guide
+bundle install
rails generate scaffold bird name:string
rake db:migrate
rails server
@@ -51,44 +52,47 @@ NOTE: The aforementioned instructions will work for sqlite3. For more detailed
h4. Generate the Plugin Skeleton
-Rails ships with a plugin generator which creates a basic plugin skeleton. Pass the plugin name, either 'CamelCased' or 'under_scored', as an argument. Pass +--with-generator+ to add an example generator also.
+Rails ships with a plugin generator which creates a basic plugin skeleton. Pass the plugin name, either 'CamelCased' or 'under_scored', as an argument. Pass +--generator+ to add an example generator also.
This creates a plugin in +vendor/plugins+ including an +init.rb+ and +README+ as well as standard +lib+, +task+, and +test+ directories.
Examples:
<shell>
rails generate plugin yaffle
-rails generate plugin yaffle --with-generator
+rails generate plugin yaffle --generator
</shell>
To get more detailed help on the plugin generator, type +rails generate plugin+.
-Later on this guide will describe how to work with generators, so go ahead and generate your plugin with the +--with-generator+ option now:
+Later on this guide will describe how to work with generators, so go ahead and generate your plugin with the +--generator+ option now:
<shell>
-rails generate plugin yaffle --with-generator
+rails generate plugin yaffle --generator
</shell>
You should see the following output:
<shell>
-create vendor/plugins/yaffle/lib
-create vendor/plugins/yaffle/tasks
-create vendor/plugins/yaffle/test
-create vendor/plugins/yaffle/README
-create vendor/plugins/yaffle/MIT-LICENSE
-create vendor/plugins/yaffle/Rakefile
+create vendor/plugins/yaffle
create vendor/plugins/yaffle/init.rb
create vendor/plugins/yaffle/install.rb
+create vendor/plugins/yaffle/MIT-LICENSE
+create vendor/plugins/yaffle/Rakefile
+create vendor/plugins/yaffle/README
create vendor/plugins/yaffle/uninstall.rb
+create vendor/plugins/yaffle/lib
create vendor/plugins/yaffle/lib/yaffle.rb
-create vendor/plugins/yaffle/tasks/yaffle_tasks.rake
-create vendor/plugins/yaffle/test/core_ext_test.rb
-create vendor/plugins/yaffle/generators
-create vendor/plugins/yaffle/generators/yaffle
-create vendor/plugins/yaffle/generators/yaffle/templates
-create vendor/plugins/yaffle/generators/yaffle/yaffle_generator.rb
-create vendor/plugins/yaffle/generators/yaffle/USAGE
+invoke generator
+inside vendor/plugins/yaffle
+create lib/generators
+create lib/generators/yaffle_generator.rb
+create lib/generators/USAGE
+create lib/generators/templates
+invoke test_unit
+inside vendor/plugins/yaffle
+create test
+create test/yaffle_test.rb
+create test/test_helper.rb
</shell>
h4. Organize Your Files
@@ -99,9 +103,7 @@ To make it easy to organize your files and to make the plugin more compatible wi
|-- lib
| |-- yaffle
| `-- yaffle.rb
-`-- rails
- |
- `-- init.rb
+`-- init.rb
</shell>
<ruby>
@@ -126,26 +128,26 @@ h4. Test Setup
# vendor/plugins/yaffle/test/database.yml
sqlite:
- :adapter: sqlite
- :dbfile: vendor/plugins/yaffle/test/yaffle_plugin.sqlite.db
+ adapter: sqlite
+ database: vendor/plugins/yaffle/test/yaffle_plugin.sqlite.db
sqlite3:
- :adapter: sqlite3
- :dbfile: vendor/plugins/yaffle/test/yaffle_plugin.sqlite3.db
+ adapter: sqlite3
+ database: vendor/plugins/yaffle/test/yaffle_plugin.sqlite3.db
postgresql:
- :adapter: postgresql
- :username: postgres
- :password: postgres
- :database: yaffle_plugin_test
- :min_messages: ERROR
+ adapter: postgresql
+ username: postgres
+ password: postgres
+ database: yaffle_plugin_test
+ min_messages: ERROR
mysql:
- :adapter: mysql
- :host: localhost
- :username: root
- :password: password
- :database: yaffle_plugin_test
+ adapter: mysql
+ host: localhost
+ username: root
+ password: password
+ database: yaffle_plugin_test
</yaml>
For this guide you'll need 2 tables/models, Hickwalls and Wickwalls, so add the following:
@@ -205,7 +207,7 @@ def load_schema
ActiveRecord::Base.establish_connection(config[db_adapter])
load(File.dirname(__FILE__) + "/schema.rb")
- require File.dirname(__FILE__) + '/../rails/init'
+ require File.dirname(__FILE__) + '/../init'
end
</ruby>
@@ -218,9 +220,9 @@ Once you have these files in place, you can write your first test to ensure that
<ruby>
# vendor/plugins/yaffle/test/yaffle_test.rb
-require File.dirname(__FILE__) + '/test_helper'
+require 'test_helper'
-class YaffleTest < Test::Unit::TestCase
+class YaffleTest < ActiveSupport::TestCase
load_schema
class Hickwall < ActiveRecord::Base
@@ -252,16 +254,18 @@ You should see output like:
-> 0.0220s
-- create_table(:wickwalls, {:force=>true})
-> 0.0077s
+-- create_table(:woodpeckers, {:force=>true})
+ -> 0.0069s
-- initialize_schema_migrations_table()
-> 0.0007s
--- assume_migrated_upto_version(0)
+-- assume_migrated_upto_version(0, "db/migrate")
-> 0.0007s
Loaded suite /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader
Started
.
Finished in 0.002236 seconds.
-1 test, 1 assertion, 0 failures, 0 errors
+1 test, 2 assertion, 0 failures, 0 errors, 0 skips
</shell>
By default the setup above runs your tests with sqlite or sqlite3. To run tests with one of the other connection strings specified in +database.yml+, pass the DB environment variable to rake:
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile
index 7e1b0c2e32..cfba58d8da 100644
--- a/railties/guides/source/routing.textile
+++ b/railties/guides/source/routing.textile
@@ -39,10 +39,10 @@ You can also generate paths and URLs. If your application contains this code:
</ruby>
<erb>
-<%= link_to "Patient Record", patients_path(@patient.id) %>
+<%= link_to "Patient Record", patient_path(@patient) %>
</erb>
-The router will generate the path +/patients/17+. This reduces the brittleness of your view and makes your code easier to understand.
+The router will generate the path +/patients/17+. This reduces the brittleness of your view and makes your code easier to understand. Note that the id does not need to be specified in the route helper.
h3. Resource Routing: the Rails Default
@@ -91,7 +91,7 @@ Creating a resourceful route will also expose a number of helpers to the control
* +photos_path+ returns +/photos+
* +new_photo_path+ returns +/photos/new+
-* +edit_photo_path+ returns +/photos/edit+
+* +edit_photo_path+ returns +/photos/:id/edit+
* +photo_path(id)+ returns +/photos/:id+ (for instance, +photo_path(10)+ returns +/photos/10+)
Each of these helpers has a corresponding +_url+ helper (such as +photos_url+) which returns the same path prefixed with the current host, port and path prefix.
@@ -116,7 +116,7 @@ resources :videos
h4. Singular Resources
-Sometimes, you have a resource that clients always look up without referencing an ID. A common example, +/profile+ always shows the profile of the currently logged in user. In this case, you can use a singular resource to map +/profile+ (rather than +/profile/:id+) to the +show+ action.
+Sometimes, you have a resource that clients always look up without referencing an ID. For example, you would like +/profile+ to always show the profile of the currently logged in user. In this case, you can use a singular resource to map +/profile+ (rather than +/profile/:id+) to the +show+ action.
<ruby>
match "profile" => "users#show"
@@ -370,7 +370,7 @@ When you set up a regular route, you supply a series of symbols that Rails maps
match ':controller(/:action(/:id))'
</ruby>
-If an incoming request of +/photos/show/1+ is processed by this route (because it hasn't matched any previous route in the file), then the result will be to invoke the +show+ action of the +PhotosController+, and to make the final parameter +"1"+ available as +params[:id]+. This route will also route the incoming request of +/photos+ to +PhotosController+, since +:action+ and +:id+ are optional parameters, denoted by parentheses.
+If an incoming request of +/photos/show/1+ is processed by this route (because it hasn't matched any previous route in the file), then the result will be to invoke the +show+ action of the +PhotosController+, and to make the final parameter +"1"+ available as +params[:id]+. This route will also route the incoming request of +/photos+ to +PhotosController#index+, since +:action+ and +:id+ are optional parameters, denoted by parentheses.
h4. Dynamic Segments
@@ -434,7 +434,7 @@ You can specify a name for any route using the +:as+ option.
match 'exit' => 'sessions#destroy', :as => :logout
</ruby>
-This will create +logout_path+ and +logout_url+ as named helpers in your application. Calling +logout_path+ will return +/logout+
+This will create +logout_path+ and +logout_url+ as named helpers in your application. Calling +logout_path+ will return +/exit+
h4. Segment Constraints