1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

1.9 Hash Syntax

This commit is contained in:
Akira Matsuda 2013-07-08 17:18:53 +09:00
parent 19df76f75e
commit 874fbdaad6
4 changed files with 4 additions and 4 deletions

View file

@ -1492,7 +1492,7 @@ number_to_human_size(1234567) # => 1.2 MB
Formats a number as a percentage string.
```ruby
number_to_percentage(100, :precision => 0) # => 100%
number_to_percentage(100, precision: 0) # => 100%
```
#### number_to_phone

View file

@ -343,7 +343,7 @@ By using the `after_commit` callback we can account for this case.
```ruby
class PictureFile < ActiveRecord::Base
after_commit :delete_picture_file_from_disk, :on => [:destroy]
after_commit :delete_picture_file_from_disk, on: [:destroy]
def delete_picture_file_from_disk
if File.exist?(filepath)

View file

@ -711,7 +711,7 @@ Post.order('id DESC').limit(20).unscope(:order, :limit) = Post.all
You can additionally unscope specific where clauses. For example:
```ruby
Post.where(:id => 10).limit(1).unscope(where: :id, :limit).order('id DESC') = Post.order('id DESC')
Post.where(id: 10).limit(1).unscope(where: :id, :limit).order('id DESC') = Post.order('id DESC')
```
### `only`

View file

@ -19,7 +19,7 @@ Ruby on Rails Guides
<h3><%= section['name'] %></h3>
<dl>
<% section['documents'].each do |document| %>
<%= guide(document['name'], document['url'], :work_in_progress => document['work_in_progress']) do %>
<%= guide(document['name'], document['url'], work_in_progress: document['work_in_progress']) do %>
<p><%= document['description'] %></p>
<% end %>
<% end %>