diff options
author | Aleksey Magusev <lexmag@gmail.com> | 2012-07-19 00:24:21 +0400 |
---|---|---|
committer | Aleksey Magusev <lexmag@gmail.com> | 2012-07-19 00:24:21 +0400 |
commit | 5a7d31913bb16977ec85d55de34ac0d79b512d62 (patch) | |
tree | fe178a7dc9532832a8ec8ea992f28a29cae61320 /railties/lib/rails/generators | |
parent | fe5b943d9fd389f313dd87bf73b7c11b8746227b (diff) | |
download | rails-5a7d31913bb16977ec85d55de34ac0d79b512d62.tar.gz rails-5a7d31913bb16977ec85d55de34ac0d79b512d62.tar.bz2 rails-5a7d31913bb16977ec85d55de34ac0d79b512d62.zip |
Add fkey attributes to `join_table` migration generator
Diffstat (limited to 'railties/lib/rails/generators')
-rw-r--r-- | railties/lib/rails/generators/generated_attribute.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb index 35cd40d25e..d2c2abf40c 100644 --- a/railties/lib/rails/generators/generated_attribute.rb +++ b/railties/lib/rails/generators/generated_attribute.rb @@ -90,8 +90,12 @@ module Rails end end + def plural_name + name.sub(/_id$/, '').pluralize + end + def human_name - name.to_s.humanize + name.humanize end def index_name @@ -102,6 +106,10 @@ module Rails end end + def foreign_key? + !!(name =~ /_id$/) + end + def reference? self.class.reference?(type) end |