diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2019-04-02 19:13:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-02 19:13:25 -0400 |
commit | 6c6c579a9b72ee676b24a900bebe3e5df161c119 (patch) | |
tree | 54f97c504eece22db3e1a44c5d956868b3a68468 /activerecord/lib | |
parent | 736c7d5995265e5fe004658a10f6fe38a49a31bd (diff) | |
parent | ecdcf06cb2e19e4bd2d883fbf3908cf196cfc1a5 (diff) | |
download | rails-6c6c579a9b72ee676b24a900bebe3e5df161c119.tar.gz rails-6c6c579a9b72ee676b24a900bebe3e5df161c119.tar.bz2 rails-6c6c579a9b72ee676b24a900bebe3e5df161c119.zip |
Merge pull request #35805 from excid3/attachments-field-generators
Add attachment and attachments field generators
Diffstat (limited to 'activerecord/lib')
-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 -%> |