Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/lifo/docrails
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Dec 20, 2010
2 parents 0cbfd6c + 6909fb6 commit 880f841
Show file tree
Hide file tree
Showing 19 changed files with 118 additions and 77 deletions.
2 changes: 1 addition & 1 deletion actionmailer/README.rdoc
Expand Up @@ -59,7 +59,7 @@ generated would look like this:

Mr. david@loudthinking.com

In previous version of rails you would call <tt>create_method_name</tt> and
In previous version of Rails you would call <tt>create_method_name</tt> and
<tt>deliver_method_name</tt>. Rails 3.0 has a much simpler interface, you
simply call the method and optionally call +deliver+ on the return value.

Expand Down
2 changes: 1 addition & 1 deletion actionpack/README.rdoc
Expand Up @@ -262,7 +262,7 @@ methods:
layout "weblog/layout"

def index
@posts = Post.find(:all)
@posts = Post.all
end

def show
Expand Down
12 changes: 6 additions & 6 deletions actionpack/lib/action_controller/metal/mime_responds.rb
Expand Up @@ -63,13 +63,13 @@ def clear_respond_to
# might look something like this:
#
# def index
# @people = Person.find(:all)
# @people = Person.all
# end
#
# Here's the same action, with web-service support baked in:
#
# def index
# @people = Person.find(:all)
# @people = Person.all
#
# respond_to do |format|
# format.html
Expand Down Expand Up @@ -155,7 +155,7 @@ def clear_respond_to
# Respond to also allows you to specify a common block for different formats by using any:
#
# def index
# @people = Person.find(:all)
# @people = Person.all
#
# respond_to do |format|
# format.html
Expand All @@ -178,7 +178,7 @@ def clear_respond_to
# respond_to :html, :xml, :json
#
# def index
# @people = Person.find(:all)
# @people = Person.all
# respond_with(@person)
# end
# end
Expand Down Expand Up @@ -208,8 +208,8 @@ def respond_to(*mimes, &block)
# It also accepts a block to be given. It's used to overwrite a default
# response:
#
# def destroy
# @user = User.find(params[:id])
# def create
# @user = User.new(params[:user])
# flash[:notice] = "User was successfully created." if @user.save
#
# respond_with(@user) do |format|
Expand Down
6 changes: 3 additions & 3 deletions activemodel/README.rdoc
Expand Up @@ -84,7 +84,7 @@ modules:
attr_reader :errors

def validate!
errors.add(:name, "can not be nil") if name == nil
errors.add(:name, "can not be nil") if name.nil?
end

def ErrorsPerson.human_attribute_name(attr, options = {})
Expand All @@ -94,10 +94,10 @@ modules:
end

person.errors.full_messages
# => ["Name Can not be nil"]
# => ["Name can not be nil"]

person.errors.full_messages
# => ["Name Can not be nil"]
# => ["Name can not be nil"]

{Learn more}[link:classes/ActiveModel/Errors.html]

Expand Down
4 changes: 2 additions & 2 deletions activemodel/lib/active_model/serialization.rb
Expand Up @@ -15,7 +15,7 @@ module ActiveModel
# attr_accessor :name
#
# def attributes
# @attributes ||= {'name' => 'nil'}
# @attributes ||= {'name' => nil}
# end
#
# end
Expand Down Expand Up @@ -45,7 +45,7 @@ module ActiveModel
# attr_accessor :name
#
# def attributes
# @attributes ||= {'name' => 'nil'}
# @attributes ||= {'name' => nil}
# end
#
# end
Expand Down
4 changes: 2 additions & 2 deletions activerecord/README.rdoc
Expand Up @@ -84,7 +84,7 @@ A short rundown of some of the major features:

class CommentObserver < ActiveRecord::Observer
def after_create(comment) # is called just after Comment#save
Notifications.deliver_new_comment("david@loudthinking.com", comment)
CommentMailer.new_comment_email("david@loudthinking.com", comment)
end
end

Expand Down Expand Up @@ -128,7 +128,7 @@ A short rundown of some of the major features:

# connect to MySQL with authentication
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:adapter => "mysql2",
:host => "localhost",
:username => "me",
:password => "secret",
Expand Down
2 changes: 1 addition & 1 deletion activeresource/README.rdoc
Expand Up @@ -95,7 +95,7 @@ Collections can also be requested in a similar fashion
#
# for GET http://api.people.com:3000/people.xml
#
people = Person.find(:all)
people = Person.all
people.first # => <Person::xxx 'first' => 'Ryan' ...>
people.last # => <Person::xxx 'first' => 'Jim' ...>

Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/concern.rb
Expand Up @@ -3,7 +3,7 @@ module ActiveSupport
#
# module M
# def self.included(base)
# base.extend, ClassMethods
# base.extend ClassMethods
# base.send(:include, InstanceMethods)
# scope :disabled, where(:disabled => true)
# end
Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/action_mailer_basics.textile
Expand Up @@ -248,7 +248,7 @@ It is possible to send email to one or more recipients in one email (for e.g. in
class AdminMailer < ActionMailer::Base
default :to => Admin.all.map(&:email).join(", "),
:from => "notification@example.com"

def new_registration(user)
@user = user
mail(:subject => "New User Signup: #{@user.email}")
Expand Down
4 changes: 2 additions & 2 deletions railties/guides/source/active_support_core_extensions.textile
Expand Up @@ -3389,12 +3389,12 @@ Modifies the datetime format output by the formatter class associated with this
<ruby>
class Logger::FormatWithTime < Logger::Formatter
cattr_accessor(:datetime_format) { "%Y%m%d%H%m%S" }

def self.call(severity, timestamp, progname, msg)
"#{timestamp.strftime(datetime_format)} -- #{String === msg ? msg : msg.inspect}\n"
end
end

logger = Logger.new("log/development.log")
logger.formatter = Logger::FormatWithTime
logger.info("<- is the current time")
Expand Down
4 changes: 2 additions & 2 deletions railties/guides/source/api_documentation_guidelines.textile
Expand Up @@ -46,10 +46,10 @@ Short docs do not need an explicit "Examples" label to introduce snippets, they
# Converts a collection of elements into a formatted string by calling
# <tt>to_s</tt> on all elements and joining them.
#
# Blog.find(:all).to_formatted_s # => "First PostSecond PostThird Post"
# Blog.all.to_formatted_s # => "First PostSecond PostThird Post"
</ruby>

On the other hand big chunks of structured documentation may have a separate "Examples" section:
On the other hand, big chunks of structured documentation may have a separate "Examples" section:

<ruby>
# ==== Examples
Expand Down
14 changes: 10 additions & 4 deletions railties/guides/source/configuring.textile
Expand Up @@ -190,6 +190,12 @@ Middlewares can also be completely swapped out and replaced with others:
config.middleware.swap ActionDispatch::BestStandardsSupport, Magical::Unicorns
</ruby>

They can also be removed from the stack completely:

<ruby>
config.middleware.delete ActionDispatch::BestStandardsSupport
</ruby>

h4. Configuring i18n

* +config.i18n.default_locale+ sets the default locale of an application used for i18n. Defaults to +:en+.
Expand Down Expand Up @@ -272,11 +278,11 @@ h4. Configuring Action Dispatch

* +config.action_dispatch.tld_length+ sets the TLD (top-level domain) length for the application. Defaults to +1+.

* +ActionDispatch::Callbacks.before+ takes a block of code to run before the request.
* +ActionDispatch::Callbacks.before+ takes a block of code to run before the request.

* +ActionDispatch::Callbacks.to_prepare+ takes a block to run after +ActionDispatch::Callbacks.before+, but before the request. Runs for every request in +development+ mode, but only once for +production+ or environments with +cache_classes+ set to +true+.

* +ActionDispatch::Callbacks.after+ takes a block of code to run after the request.
* +ActionDispatch::Callbacks.after+ takes a block of code to run after the request.

h4. Configuring Action View

Expand Down Expand Up @@ -392,7 +398,7 @@ Rails has 5 initialization events which can be hooked into (listed in order that

* +before_initialize+: This is run directly before the initialization process of the application occurs with the +:bootstrap_hook+ initializer near the beginning of the Rails initialization process.

* +to_prepare+: Run after the initializers are ran for all Railties (including the application itself), but before eager loading and the middleware stack is built.
* +to_prepare+: Run after the initializers are ran for all Railties (including the application itself), but before eager loading and the middleware stack is built.

* +before_eager_load+: This is run directly before eager loading occurs, which is the default behaviour for the _production_ environment and not for the +development+ enviroment.

Expand All @@ -411,7 +417,7 @@ initializer "active_support.initialize_whiny_nils" do |app|
end
</ruby>

The +initializer+ method takes three arguments with the first being the name for the initializer and the second being an options hash (not shown here) and the third being a block. The +:before+ key in the options hash can be specified to specify which initializer this new initializer must run before, and the +:after+ key will specify which initializer to run this initializer _after_.
The +initializer+ method takes three arguments with the first being the name for the initializer and the second being an options hash (not shown here) and the third being a block. The +:before+ key in the options hash can be specified to specify which initializer this new initializer must run before, and the +:after+ key will specify which initializer to run this initializer _after_.

Initializers defined using the +initializer+ method will be ran in the order they are defined in, with the exception of ones that use the +:before+ or +:after+ methods.

Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/form_helpers.textile
Expand Up @@ -644,7 +644,7 @@ Fundamentally HTML forms don't know about any sort of structured data, all they
TIP: You may find you can try out examples in this section faster by using the console to directly invoke Rails' parameter parser. For example,

<ruby>
ActionController::UrlEncodedPairParser.parse_query_parameters "name=fred&phone=0123456789"
ActionController::UrlEncodedPairParser.parse_query_parameters "name=fred&phone=0123456789"
# => {"name"=>"fred", "phone"=>"0123456789"}
</ruby>

Expand Down
65 changes: 32 additions & 33 deletions railties/guides/source/generators.textile
Expand Up @@ -371,16 +371,16 @@ h3. Application templates
Now that you've seen how generators can be used _inside_ an application, did you know they can also be used to _generate_ applications too? This kind of generator is referred as a "template".

<ruby>
gem("rspec-rails", :group => "test")
gem("cucumber-rails", :group => "test")

if yes?("Would you like to install Devise?")
gem("devise")
generate("devise:install")
model_name = ask("What would you like the user model to be called? [user]")
model_name = "user" if model_name.blank?
generate("devise", model_name)
end
gem("rspec-rails", :group => "test")
gem("cucumber-rails", :group => "test")

if yes?("Would you like to install Devise?")
gem("devise")
generate("devise:install")
model_name = ask("What would you like the user model to be called? [user]")
model_name = "user" if model_name.blank?
generate("devise", model_name)
end
</ruby>

In the above template we specify that the application relies on the +rspec-rails+ and +cucumber-rails+ gem so these two will be added to the +test+ group in the +Gemfile+. Then we pose a question to the user about whether or not they would like to install Devise. If the user replies "y" or "yes" to this question, then the template will add Devise to the +Gemfile+ outside of any group and then runs the +devise:install+ generator. This template then takes the users input and runs the +devise+ generator, with the user's answer from the last question being passed to this generator.
Expand All @@ -403,7 +403,7 @@ Whilst the final section of this guide doesn't cover how to generate the most aw

h3. Generator methods

The following are methods available for both generators and templates for Rails.
The following are methods available for both generators and templates for Rails.

NOTE: Methods provided by Thor are not covered this guide and can be found in "Thor's documentation":http://rdoc.info/github/wycats/thor/master/Thor/Actions.html

Expand All @@ -428,8 +428,8 @@ h4. +gem+
Specifies a gem dependency of the application.

<ruby>
gem("rspec", :group => "test", :version => "2.1.0")
gem("devise", "1.1.5")
gem("rspec", :group => "test", :version => "2.1.0")
gem("devise", "1.1.5")
</ruby>

Available options are:
Expand Down Expand Up @@ -470,20 +470,19 @@ Adds a line to +config/application.rb+ directly after the application class defi
This method can also take a block:

<ruby>
application do
"config.asset_host = 'http://example.com'"
end
end
application do
"config.asset_host = 'http://example.com'"
end
</ruby>

Available options are:

* +:env+ - Specify an environment for this configuration option. If you wish to use this option with the block syntax the recommended syntax is as follows:

<ruby>
application(nil, :env => "development") do
"config.asset_host = 'http://localhost:3000'"
end
application(nil, :env => "development") do
"config.asset_host = 'http://localhost:3000'"
end
</ruby>

h4. +git+
Expand Down Expand Up @@ -526,9 +525,9 @@ Places a file into +lib+ which contains the specified code.
This method also takes a block:

<ruby>
lib("super_special.rb") do
puts "Super special!"
end
lib("super_special.rb") do
puts "Super special!"
end
</ruby>

h4. +rakefile+
Expand All @@ -542,13 +541,13 @@ Creates a Rake file in the +lib/tasks+ directory of the application.
This method also takes a block:

<ruby>
rakefile("test.rake") do
%Q{
task :rock => :environment do
puts "Rockin'"
end
}
end
rakefile("test.rake") do
%Q{
task :rock => :environment do
puts "Rockin'"
end
}
end
</ruby>

h4. +initializer+
Expand All @@ -562,9 +561,9 @@ Creates an initializer in the +config/initializers+ directory of the application
This method also takes a block:

<ruby>
initializer("begin.rb") do
puts "Almost done!"
end
initializer("begin.rb") do
puts "Almost done!"
end
</ruby>

h4. +generate+
Expand Down
8 changes: 4 additions & 4 deletions railties/guides/source/i18n.textile
Expand Up @@ -852,7 +852,7 @@ h3. Conclusion

At this point you should have a good overview about how I18n support in Ruby on Rails works and are ready to start translating your project.

If you find anything missing or wrong in this guide please file a ticket on "our issue tracker":http://i18n.lighthouseapp.com/projects/14948-rails-i18n/overview. If you want to discuss certain portions or have questions please sign up to our "mailinglist":http://groups.google.com/group/rails-i18n.
If you find anything missing or wrong in this guide, please file a ticket on our "issue tracker":http://i18n.lighthouseapp.com/projects/14948-rails-i18n/overview. If you want to discuss certain portions or have questions, please sign up to our "mailing list":http://groups.google.com/group/rails-i18n.


h3. Contributing to Rails I18n
Expand All @@ -867,10 +867,10 @@ If you find your own locale (language) missing from our "example translations da
h3. Resources

* "rails-i18n.org":http://rails-i18n.org - Homepage of the rails-i18n project. You can find lots of useful resources on the "wiki":http://rails-i18n.org/wiki.
* "rails-i18n Google group":http://groups.google.com/group/rails-i18n - The project's mailing list.
* "Google group: rails-i18n":http://groups.google.com/group/rails-i18n - The project's mailing list.
* "Github: rails-i18n":http://github.com/svenfuchs/rails-i18n/tree/master - Code repository for the rails-i18n project. Most importantly you can find lots of "example translations":http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale for Rails that should work for your application in most cases.
* "Lighthouse: rails-i18n":http://i18n.lighthouseapp.com/projects/14948-rails-i18n/overview - Issue tracker for the rails-i18n project.
* "Github: i18n":http://github.com/svenfuchs/i18n/tree/master - Code repository for the i18n gem.
* "Lighthouse: rails-i18n":http://i18n.lighthouseapp.com/projects/14948-rails-i18n/overview - Issue tracker for the rails-i18n project.
* "Lighthouse: i18n":http://i18n.lighthouseapp.com/projects/14947-ruby-i18n/overview - Issue tracker for the i18n gem.


Expand All @@ -879,7 +879,7 @@ h3. Authors
* "Sven Fuchs":http://www.workingwithrails.com/person/9963-sven-fuchs (initial author)
* "Karel Minařík":http://www.workingwithrails.com/person/7476-karel-mina-k

If you found this guide useful please consider recommending its authors on "workingwithrails":http://www.workingwithrails.com.
If you found this guide useful, please consider recommending its authors on "workingwithrails":http://www.workingwithrails.com.


h3. Footnotes
Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/index.html.erb
Expand Up @@ -161,7 +161,7 @@ Ruby on Rails Guides
<%= guide('API Documentation Guidelines', 'api_documentation_guidelines.html') do %>
<p>This guide documents the Ruby on Rails API documentation guidelines.</p>
<% end %>
<%= guide('Ruby on Rails Guides Guidelines', 'ruby_on_rails_guides_guidelines.html') do %>
<p>This guide documents the Ruby on Rails guides guidelines.</p>
<% end %>
Expand Down

0 comments on commit 880f841

Please sign in to comment.