diff options
author | Chris Oliver <excid3@gmail.com> | 2019-03-30 11:54:47 -0500 |
---|---|---|
committer | Chris Oliver <excid3@gmail.com> | 2019-03-30 12:15:17 -0500 |
commit | ecdcf06cb2e19e4bd2d883fbf3908cf196cfc1a5 (patch) | |
tree | 8903a538961ce8c85a7ef1c5fcbec11c4c18e38b /activerecord/lib/rails/generators | |
parent | 4e076b03b6312b928a845f9a31288d10d7243338 (diff) | |
download | rails-ecdcf06cb2e19e4bd2d883fbf3908cf196cfc1a5.tar.gz rails-ecdcf06cb2e19e4bd2d883fbf3908cf196cfc1a5.tar.bz2 rails-ecdcf06cb2e19e4bd2d883fbf3908cf196cfc1a5.zip |
Add attachment and attachments field generators
Diffstat (limited to 'activerecord/lib/rails/generators')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/model/templates/model.rb.tt | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/rails/generators/active_record/model/templates/model.rb.tt b/activerecord/lib/rails/generators/active_record/model/templates/model.rb.tt index cdd029735a..c1c03e2762 100644 --- a/activerecord/lib/rails/generators/active_record/model/templates/model.rb.tt +++ b/activerecord/lib/rails/generators/active_record/model/templates/model.rb.tt @@ -6,6 +6,12 @@ class <%= class_name %> < <%= parent_class_name.classify %> <% attributes.select(&:rich_text?).each do |attribute| -%> has_rich_text :<%= attribute.name %> <% end -%> +<% attributes.select(&:attachment?).each do |attribute| -%> + has_one_attached :<%= attribute.name %> +<% end -%> +<% attributes.select(&:attachments?).each do |attribute| -%> + has_many_attached :<%= attribute.name %> +<% end -%> <% attributes.select(&:token?).each do |attribute| -%> has_secure_token<% if attribute.name != "token" %> :<%= attribute.name %><% end %> <% end -%> |