mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove double spaces in code examples
This commit is contained in:
parent
606c09b8db
commit
70b302b189
7 changed files with 12 additions and 12 deletions
|
@ -173,8 +173,8 @@ before_save :update_credit_rating, :if => :active,
|
|||
Rails now has a `:having` option on find (as well as on `has_many` and `has_and_belongs_to_many` associations) for filtering records in grouped finds. As those with heavy SQL backgrounds know, this allows filtering based on grouped results:
|
||||
|
||||
```ruby
|
||||
developers = Developer.find(:all, :group => "salary",
|
||||
:having => "sum(salary) > 10000", :select => "salary")
|
||||
developers = Developer.find(:all, :group => "salary",
|
||||
:having => "sum(salary) > 10000", :select => "salary")
|
||||
```
|
||||
|
||||
* Lead Contributor: [Emilio Tagua](http://github.com/miloops)
|
||||
|
|
|
@ -1229,7 +1229,7 @@ One important caveat is that `default_scope` will be overridden by
|
|||
|
||||
```ruby
|
||||
class User < ActiveRecord::Base
|
||||
default_scope { where state: 'pending' }
|
||||
default_scope { where state: 'pending' }
|
||||
scope :active, -> { where state: 'active' }
|
||||
scope :inactive, -> { where state: 'inactive' }
|
||||
end
|
||||
|
|
|
@ -885,7 +885,7 @@ end
|
|||
:name => 'John Doe',
|
||||
:addresses_attributes => {
|
||||
'0' => {
|
||||
:kind => 'Home',
|
||||
:kind => 'Home',
|
||||
:street => '221b Baker Street',
|
||||
},
|
||||
'1' => {
|
||||
|
|
|
@ -174,7 +174,7 @@ end
|
|||
# in your /etc/hosts file to try this out locally
|
||||
def extract_locale_from_tld
|
||||
parsed_locale = request.host.split('.').last
|
||||
I18n.available_locales.include?(parsed_locale.to_sym) ? parsed_locale : nil
|
||||
I18n.available_locales.include?(parsed_locale.to_sym) ? parsed_locale : nil
|
||||
end
|
||||
```
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ This file is as follows:
|
|||
|
||||
```ruby
|
||||
#!/usr/bin/env ruby
|
||||
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
||||
require File.expand_path('../../config/boot', __FILE__)
|
||||
require 'rails/commands'
|
||||
```
|
||||
|
||||
|
@ -373,7 +373,7 @@ The `options[:config]` value defaults to `config.ru` which contains this:
|
|||
```ruby
|
||||
# This file is used by Rack-based servers to start the application.
|
||||
|
||||
require ::File.expand_path('../config/environment', __FILE__)
|
||||
require ::File.expand_path('../config/environment', __FILE__)
|
||||
run <%= app_const %>
|
||||
```
|
||||
|
||||
|
@ -388,7 +388,7 @@ app = eval "Rack::Builder.new {( " + cfgfile + "\n )}.to_app",
|
|||
The `initialize` method of `Rack::Builder` will take the block here and execute it within an instance of `Rack::Builder`. This is where the majority of the initialization process of Rails happens. The `require` line for `config/environment.rb` in `config.ru` is the first to run:
|
||||
|
||||
```ruby
|
||||
require ::File.expand_path('../config/environment', __FILE__)
|
||||
require ::File.expand_path('../config/environment', __FILE__)
|
||||
```
|
||||
|
||||
### `config/environment.rb`
|
||||
|
@ -546,7 +546,7 @@ def self.run(app, options={})
|
|||
else
|
||||
server.register('/', Rack::Handler::Mongrel.new(app))
|
||||
end
|
||||
yield server if block_given?
|
||||
yield server if block_given?
|
||||
server.run.join
|
||||
end
|
||||
```
|
||||
|
|
|
@ -877,7 +877,7 @@ end
|
|||
# app/models/product.rb
|
||||
|
||||
class Product < ActiveRecord::Base
|
||||
validates :flag, inclusion: { in: [true, false] }
|
||||
validates :flag, inclusion: { in: [true, false] }
|
||||
validates :fuzz, presence: true
|
||||
end
|
||||
```
|
||||
|
|
|
@ -82,7 +82,7 @@ To use `rackup` instead of Rails' `rails server`, you can put the following insi
|
|||
|
||||
```ruby
|
||||
# Rails.root/config.ru
|
||||
require ::File.expand_path('../config/environment', __FILE__)
|
||||
require ::File.expand_path('../config/environment', __FILE__)
|
||||
|
||||
use Rack::Debugger
|
||||
use Rack::ContentLength
|
||||
|
|
Loading…
Reference in a new issue