update code examples to 1.9 hash syntax in the AR/README [ci skip]
This commit is contained in:
parent
d71d5ba71f
commit
82355dfb35
|
@ -49,10 +49,10 @@ A short rundown of some of the major features:
|
||||||
* Aggregations of value objects.
|
* Aggregations of value objects.
|
||||||
|
|
||||||
class Account < ActiveRecord::Base
|
class Account < ActiveRecord::Base
|
||||||
composed_of :balance, :class_name => "Money",
|
composed_of :balance, class_name: 'Money',
|
||||||
:mapping => %w(balance amount)
|
mapping: %w(balance amount)
|
||||||
composed_of :address,
|
composed_of :address,
|
||||||
:mapping => [%w(address_street street), %w(address_city city)]
|
mapping: [%w(address_street street), %w(address_city city)]
|
||||||
end
|
end
|
||||||
|
|
||||||
{Learn more}[link:classes/ActiveRecord/Aggregations/ClassMethods.html]
|
{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
|
class CommentObserver < ActiveRecord::Observer
|
||||||
def after_create(comment) # is called just after Comment#save
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -124,15 +124,15 @@ A short rundown of some of the major features:
|
||||||
* Database abstraction through simple adapters.
|
* Database abstraction through simple adapters.
|
||||||
|
|
||||||
# connect to SQLite3
|
# 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
|
# connect to MySQL with authentication
|
||||||
ActiveRecord::Base.establish_connection(
|
ActiveRecord::Base.establish_connection(
|
||||||
:adapter => "mysql2",
|
adapter: 'mysql2',
|
||||||
:host => "localhost",
|
host: 'localhost',
|
||||||
:username => "me",
|
username: 'me',
|
||||||
:password => "secret",
|
password: 'secret',
|
||||||
:database => "activerecord"
|
database: 'activerecord'
|
||||||
)
|
)
|
||||||
|
|
||||||
{Learn more}[link:classes/ActiveRecord/Base.html] and read about the built-in support for
|
{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].
|
* 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 = 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.
|
* Database agnostic schema management with Migrations.
|
||||||
|
@ -159,7 +159,7 @@ A short rundown of some of the major features:
|
||||||
t.integer :position
|
t.integer :position
|
||||||
end
|
end
|
||||||
|
|
||||||
SystemSetting.create :name => "notice", :label => "Use notice?", :value => 1
|
SystemSetting.create name: 'notice', label: 'Use notice?', value: 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
|
Loading…
Reference in New Issue