mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
update code examples to 1.9 hash syntax in the AR/README [ci skip]
This commit is contained in:
parent
d71d5ba71f
commit
82355dfb35
1 changed files with 12 additions and 12 deletions
|
@ -49,10 +49,10 @@ A short rundown of some of the major features:
|
|||
* Aggregations of value objects.
|
||||
|
||||
class Account < ActiveRecord::Base
|
||||
composed_of :balance, :class_name => "Money",
|
||||
:mapping => %w(balance amount)
|
||||
composed_of :balance, class_name: 'Money',
|
||||
mapping: %w(balance amount)
|
||||
composed_of :address,
|
||||
:mapping => [%w(address_street street), %w(address_city city)]
|
||||
mapping: [%w(address_street street), %w(address_city city)]
|
||||
end
|
||||
|
||||
{Learn more}[link:classes/ActiveRecord/Aggregations/ClassMethods.html]
|
||||
|
@ -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
|
||||
CommentMailer.new_comment_email("david@loudthinking.com", comment).deliver
|
||||
CommentMailer.new_comment_email('david@loudthinking.com', comment).deliver
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -124,15 +124,15 @@ A short rundown of some of the major features:
|
|||
* Database abstraction through simple adapters.
|
||||
|
||||
# connect to SQLite3
|
||||
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => "dbfile.sqlite3")
|
||||
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'dbfile.sqlite3')
|
||||
|
||||
# connect to MySQL with authentication
|
||||
ActiveRecord::Base.establish_connection(
|
||||
:adapter => "mysql2",
|
||||
:host => "localhost",
|
||||
:username => "me",
|
||||
:password => "secret",
|
||||
:database => "activerecord"
|
||||
adapter: 'mysql2',
|
||||
host: 'localhost',
|
||||
username: 'me',
|
||||
password: 'secret',
|
||||
database: 'activerecord'
|
||||
)
|
||||
|
||||
{Learn more}[link:classes/ActiveRecord/Base.html] and read about the built-in support for
|
||||
|
@ -144,7 +144,7 @@ A short rundown of some of the major features:
|
|||
* Logging support for Log4r[http://log4r.sourceforge.net] and Logger[http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc].
|
||||
|
||||
ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT)
|
||||
ActiveRecord::Base.logger = Log4r::Logger.new("Application Log")
|
||||
ActiveRecord::Base.logger = Log4r::Logger.new('Application Log')
|
||||
|
||||
|
||||
* Database agnostic schema management with Migrations.
|
||||
|
@ -159,7 +159,7 @@ A short rundown of some of the major features:
|
|||
t.integer :position
|
||||
end
|
||||
|
||||
SystemSetting.create :name => "notice", :label => "Use notice?", :value => 1
|
||||
SystemSetting.create name: 'notice', label: 'Use notice?', value: 1
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
Loading…
Reference in a new issue