diff options
author | Paul Nikitochkin <paul.nikitochkin@gmail.com> | 2013-09-06 21:41:04 +0300 |
---|---|---|
committer | Paul Nikitochkin <paul.nikitochkin@gmail.com> | 2013-09-06 21:42:29 +0300 |
commit | 2c8bc2cdcdb7b144b7a583d24922fd8064bcff3d (patch) | |
tree | 279e76293ba90dcc46e7716ecf78fbc1df221e79 /guides/source/active_record_callbacks.md | |
parent | 97a19c6b4b71d1e12d62d880ec8c8eed357b3d3c (diff) | |
download | rails-2c8bc2cdcdb7b144b7a583d24922fd8064bcff3d.tar.gz rails-2c8bc2cdcdb7b144b7a583d24922fd8064bcff3d.tar.bz2 rails-2c8bc2cdcdb7b144b7a583d24922fd8064bcff3d.zip |
Use Ruby on Rails Coding Conventions for code examples in the guides
* Indent after private/protected
* Ruby >= 1.9 syntax for hashes
* Prefer method { do_stuff } instead of method{do_stuff} for single-line blocks.
[ci skip]
Diffstat (limited to 'guides/source/active_record_callbacks.md')
-rw-r--r-- | guides/source/active_record_callbacks.md | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/guides/source/active_record_callbacks.md b/guides/source/active_record_callbacks.md index 95eb84dd1f..aa2ce99f6d 100644 --- a/guides/source/active_record_callbacks.md +++ b/guides/source/active_record_callbacks.md @@ -35,11 +35,11 @@ class User < ActiveRecord::Base before_validation :ensure_login_has_a_value protected - def ensure_login_has_a_value - if login.nil? - self.login = email unless email.blank? + def ensure_login_has_a_value + if login.nil? + self.login = email unless email.blank? + end end - end end ``` @@ -65,13 +65,13 @@ class User < ActiveRecord::Base after_validation :set_location, on: [ :create, :update ] protected - def normalize_name - self.name = self.name.downcase.titleize - end + def normalize_name + self.name = self.name.downcase.titleize + end - def set_location - self.location = LocationService.query(self) - end + def set_location + self.location = LocationService.query(self) + end end ``` |