aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/rails/generators/active_record/model/templates
diff options
context:
space:
mode:
authorAleksey Magusev <lexmag@gmail.com>2012-06-25 22:01:31 +0400
committerAleksey Magusev <lexmag@gmail.com>2012-06-27 18:12:28 +0400
commit94b230e189e7241b96dcbfb41ceabedf7cfd14ac (patch)
tree58663586bb6cf80f19c36f20575b1ef53e393cc0 /activerecord/lib/rails/generators/active_record/model/templates
parent51b055b6d11f439ce16c30167ad807d2a7b70532 (diff)
downloadrails-94b230e189e7241b96dcbfb41ceabedf7cfd14ac.tar.gz
rails-94b230e189e7241b96dcbfb41ceabedf7cfd14ac.tar.bz2
rails-94b230e189e7241b96dcbfb41ceabedf7cfd14ac.zip
Add polymorphic option to model generator
For instance, $ rails g model Product supplier:references{polymorphic} generate model with `belongs_to :supplier, polymorphic: true` association and appropriate migration. Also fix model_generator_test.rb#L196 and #L201
Diffstat (limited to 'activerecord/lib/rails/generators/active_record/model/templates')
-rw-r--r--activerecord/lib/rails/generators/active_record/model/templates/model.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/rails/generators/active_record/model/templates/model.rb b/activerecord/lib/rails/generators/active_record/model/templates/model.rb
index d56f9f57a4..2cca17b94f 100644
--- a/activerecord/lib/rails/generators/active_record/model/templates/model.rb
+++ b/activerecord/lib/rails/generators/active_record/model/templates/model.rb
@@ -1,7 +1,7 @@
<% module_namespacing do -%>
class <%= class_name %> < <%= parent_class_name.classify %>
<% attributes.select {|attr| attr.reference? }.each do |attribute| -%>
- belongs_to :<%= attribute.name %>
+ belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %>
<% end -%>
<% if !accessible_attributes.empty? -%>
attr_accessible <%= accessible_attributes.map {|a| ":#{a.name}" }.sort.join(', ') %>