haml-rails 2.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +51 -32
  3. data/Gemfile +17 -0
  4. data/README.md +8 -3
  5. data/haml-rails.gemspec +3 -2
  6. data/lib/generators/haml/controller/controller_generator.rb +2 -0
  7. data/lib/generators/haml/mailer/mailer_generator.rb +2 -0
  8. data/lib/generators/haml/scaffold/scaffold_generator.rb +25 -10
  9. data/lib/generators/haml/scaffold/templates/5_1/_form.html.haml +26 -0
  10. data/lib/generators/haml/scaffold/templates/5_1/edit.html.haml +7 -0
  11. data/lib/generators/haml/scaffold/templates/5_1/index.html.haml +25 -0
  12. data/lib/generators/haml/scaffold/templates/5_1/new.html.haml +5 -0
  13. data/lib/generators/haml/scaffold/templates/5_1/show.html.haml +11 -0
  14. data/lib/generators/haml/scaffold/templates/5_2/_form.html.haml +26 -0
  15. data/lib/generators/haml/scaffold/templates/5_2/edit.html.haml +7 -0
  16. data/lib/generators/haml/scaffold/templates/5_2/index.html.haml +25 -0
  17. data/lib/generators/haml/scaffold/templates/5_2/new.html.haml +5 -0
  18. data/lib/generators/haml/scaffold/templates/5_2/show.html.haml +11 -0
  19. data/lib/generators/haml/scaffold/templates/6_0/_form.html.haml +29 -0
  20. data/lib/generators/haml/scaffold/templates/6_0/edit.html.haml +7 -0
  21. data/lib/generators/haml/scaffold/templates/6_0/index.html.haml +25 -0
  22. data/lib/generators/haml/scaffold/templates/6_0/new.html.haml +5 -0
  23. data/lib/generators/haml/scaffold/templates/6_0/show.html.haml +18 -0
  24. data/lib/generators/haml/scaffold/templates/6_1/_form.html.haml +29 -0
  25. data/lib/generators/haml/scaffold/templates/6_1/edit.html.haml +7 -0
  26. data/lib/generators/haml/scaffold/templates/6_1/index.html.haml +25 -0
  27. data/lib/generators/haml/scaffold/templates/6_1/new.html.haml +5 -0
  28. data/lib/generators/haml/scaffold/templates/6_1/show.html.haml +18 -0
  29. data/lib/generators/haml/scaffold/templates/7_0/_form.html.haml +29 -0
  30. data/lib/generators/haml/scaffold/templates/7_0/edit.html.haml +10 -0
  31. data/lib/generators/haml/scaffold/templates/7_0/index.html.haml +11 -0
  32. data/lib/generators/haml/scaffold/templates/7_0/new.html.haml +8 -0
  33. data/lib/generators/haml/scaffold/templates/7_0/partial.html.haml +14 -0
  34. data/lib/generators/haml/scaffold/templates/7_0/show.html.haml +10 -0
  35. data/lib/generators/haml/scaffold/templates/7_1 +1 -0
  36. data/lib/generators/haml/scaffold/templates/7_2/_form.html.haml +29 -0
  37. data/lib/generators/haml/scaffold/templates/7_2/edit.html.haml +12 -0
  38. data/lib/generators/haml/scaffold/templates/7_2/index.html.haml +13 -0
  39. data/lib/generators/haml/scaffold/templates/7_2/new.html.haml +10 -0
  40. data/lib/generators/haml/scaffold/templates/7_2/partial.html.haml +14 -0
  41. data/lib/generators/haml/scaffold/templates/7_2/show.html.haml +10 -0
  42. data/lib/generators/haml/scaffold/templates/8_0 +1 -0
  43. data/lib/generators/haml/scaffold/templates/_form.html.haml +1 -0
  44. data/lib/generators/haml/scaffold/templates/edit.html.haml +1 -0
  45. data/lib/generators/haml/scaffold/templates/index.html.haml +1 -0
  46. data/lib/generators/haml/scaffold/templates/new.html.haml +1 -0
  47. data/lib/generators/haml/scaffold/templates/partial.html.haml +1 -0
  48. data/lib/generators/haml/scaffold/templates/show.html.haml +1 -0
  49. data/lib/haml-rails/version.rb +3 -1
  50. data/lib/haml-rails.rb +2 -0
  51. data/lib/rails/generators/haml/application_layout/application_layout_generator.rb +8 -3
  52. data/test/fixtures/routes.rb +2 -0
  53. data/test/lib/generators/haml/controller_generator_test.rb +2 -0
  54. data/test/lib/generators/haml/mailer_generator_test.rb +2 -0
  55. data/test/lib/generators/haml/scaffold_generator_test.rb +2 -0
  56. data/test/lib/generators/haml/scaffold_template_contents_test.rb +76 -0
  57. data/test/test_helper.rb +30 -7
  58. metadata +45 -31
  59. data/Appraisals +0 -19
  60. data/gemfiles/rails_5_1.gemfile +0 -8
  61. data/gemfiles/rails_5_2.gemfile +0 -8
  62. data/gemfiles/rails_6_0.gemfile +0 -8
  63. data/gemfiles/rails_6_1.gemfile +0 -8
  64. data/gemfiles/rails_7_0.gemfile +0 -8
  65. data/lib/generators/haml/scaffold/templates/_form.html.haml +0 -15
  66. data/lib/generators/haml/scaffold/templates/edit.html.haml +0 -7
  67. data/lib/generators/haml/scaffold/templates/index.html.haml +0 -25
  68. data/lib/generators/haml/scaffold/templates/new.html.haml +0 -5
  69. data/lib/generators/haml/scaffold/templates/show.html.haml +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c92791c4d02db70961e18508ae709bd86a9bae7325eb8afd6f7c8286c3d7824f
4
- data.tar.gz: 0a4ad454a0c72f707159ee95c4a529cdf3c4194a64b13a690b475a1ff72687c1
3
+ metadata.gz: 675edf6edfcd12cf4e411bd43aca9143cd4ae8f0597ab5235e4ebb65fae5e4e0
4
+ data.tar.gz: 21e1357af940ed0d8c70bc561393920389547ee68d8bb319c1bfba4484343d94
5
5
  SHA512:
6
- metadata.gz: e3232df46c3893fab9e0cec861ddb8d88bfd9fe3c40bc0e05a4c67915ef58bd4f54ff9e39a4cc040853cd42fe421942629a46f31294b1622098047e42d5a89a2
7
- data.tar.gz: d25c5e7ff3ef9fb3e0879129ffe8689c9e06d2b945b404d2be3775573142645304189440deb9ca755b1d5684df1775ea707acd046d6c31f77abdb750bcd98677
6
+ metadata.gz: 75f63d2c53a4a6caaa9f8bbdfd94f629602ea13755aa085e1a30c6dff5306129e21e7ac95b3caf51d5cdd189f971c754ceb144b50a924a89b8861ee5aafab57b
7
+ data.tar.gz: 15fb9334379933441817672433b2186e1e1a3e6eb079927b42cd6807cea227eb71bbaad2f45231dd9c3ab1d41e10f8dec8b3a9ad27bcf73edbe4084b3aa2f3c6
@@ -1,10 +1,3 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
-
8
1
  name: Ruby
9
2
 
10
3
  on:
@@ -20,38 +13,64 @@ jobs:
20
13
  strategy:
21
14
  matrix:
22
15
  ruby-version:
23
- - 3.1
24
- - 3.0
25
- - 2.7
26
- - jruby
27
- gemfile:
28
- - rails_7_0
29
- - rails_6_1
30
- - rails_6_0
16
+ - '3.4'
17
+ - '3.3'
18
+ - '3.2'
19
+ - '3.1'
20
+ rails-version:
21
+ - '8.0'
22
+ - '7.2'
23
+ - '7.1'
24
+ - '7.0'
25
+ - '6.1'
31
26
 
32
27
  include:
33
- - ruby-version: 2.7
34
- gemfile: rails_5_2
35
- - ruby-version: 2.7
36
- gemfile: rails_5_1
28
+ - ruby-version: '3.1'
29
+ rails-version: '6.0'
37
30
 
38
- - ruby-version: 2.6
39
- gemfile: rails_6_1
40
- - ruby-version: 2.6
41
- gemfile: rails_6_0
42
- - ruby-version: 2.6
43
- gemfile: rails_5_2
44
- - ruby-version: 2.6
45
- gemfile: rails_5_1
31
+ - ruby-version: '3.0'
32
+ rails-version: '7.1'
33
+ - ruby-version: '3.0'
34
+ rails-version: '7.0'
35
+ - ruby-version: '3.0'
36
+ rails-version: '6.1'
37
+ - ruby-version: '3.0'
38
+ rails-version: '6.0'
39
+
40
+ - ruby-version: '2.7'
41
+ rails-version: '7.1'
42
+ - ruby-version: '2.7'
43
+ rails-version: '7.0'
44
+ - ruby-version: '2.7'
45
+ rails-version: '6.1'
46
+ - ruby-version: '2.7'
47
+ rails-version: '6.0'
48
+ - ruby-version: '2.7'
49
+ rails-version: '5.2'
50
+ - ruby-version: '2.7'
51
+ rails-version: '5.1'
52
+
53
+ - ruby-version: '2.6'
54
+ rails-version: '6.1'
55
+ - ruby-version: '2.6'
56
+ rails-version: '6.0'
57
+ - ruby-version: '2.6'
58
+ rails-version: '5.2'
59
+ - ruby-version: '2.6'
60
+ rails-version: '5.1'
46
61
 
47
- exclude:
48
62
  - ruby-version: jruby
49
- gemfile: rails_7_0
63
+ rails-version: '6.1'
64
+
65
+ exclude:
66
+ - ruby-version: '3.1'
67
+ rails-version: '8.0'
50
68
 
51
- env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
52
- BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
69
+ env:
70
+ RUBY_VERSION: ${{ matrix.ruby-version }}
71
+ RAILS_VERSION: ${{ matrix.rails-version }}
53
72
  steps:
54
- - uses: actions/checkout@v3
73
+ - uses: actions/checkout@v5
55
74
  - name: Set up Ruby
56
75
  # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
57
76
  # change this to (see https://github.com/ruby/setup-ruby#versioning):
data/Gemfile CHANGED
@@ -4,3 +4,20 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'html2haml'
7
+
8
+ if ENV['RAILS_VERSION']
9
+ gem 'rails', "~> #{ENV['RAILS_VERSION']}.0"
10
+ else
11
+ gem 'rails'
12
+ end
13
+
14
+ if RUBY_ENGINE == 'ruby'
15
+ gem 'debug'
16
+ end
17
+
18
+ if (ENV['RUBY_VERSION'] || RUBY_VERSION) >= '3.3'
19
+ gem 'mutex_m'
20
+ gem 'base64'
21
+ gem 'bigdecimal'
22
+ gem 'drb'
23
+ end
data/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # Haml-rails
2
- [![Build Status](https://travis-ci.org/haml/haml-rails.svg)](https://travis-ci.org/haml/haml-rails)
2
+ [![Gem Version](https://badge.fury.io/rb/haml-rails.svg)](https://rubygems.org/gems/haml-rails)
3
+ [![Ruby](https://github.com/haml/haml-rails/actions/workflows/ruby.yml/badge.svg)](https://github.com/haml/haml-rails/actions/workflows/ruby.yml)
3
4
 
4
- Haml-rails provides Haml generators for Rails 5. It also enables Haml as the templating engine for you, so you don't have to screw around in your own application.rb when your Gemfile already clearly indicated what templating engine you have installed. Hurrah.
5
+ Haml-rails provides Haml generators for Rails 5, 6, 7, and 8. It also enables Haml as the templating engine for you, so you don't have to screw around in your own application.rb when your Gemfile already clearly indicated what templating engine you have installed. Hurrah.
5
6
 
6
7
  To use it, add this line to your Gemfile:
7
8
 
8
- gem "haml-rails", "~> 2.0"
9
+ gem "haml-rails"
9
10
 
10
11
  This ensures that:
11
12
 
@@ -23,6 +24,10 @@ to `app/views/layouts/application.html.haml` using this command:
23
24
 
24
25
  $ rails generate haml:application_layout convert
25
26
 
27
+ This requires the html2haml gem and you can install it locally:
28
+
29
+ gem install html2haml
30
+
26
31
  After the application layout file is converted successfully,
27
32
  make sure to delete `app/views/layouts/application.html.erb`, so Rails can
28
33
  start using `app/views/layouts/application.html.haml` instead.
data/haml-rails.gemspec CHANGED
@@ -9,9 +9,11 @@ Gem::Specification.new do |s|
9
9
  s.email = ["andre@arko.net"]
10
10
  s.homepage = "https://github.com/haml/haml-rails"
11
11
  s.summary = "let your Gemfile do the configuring"
12
- s.description = "Haml-rails provides Haml generators for Rails 5. It also enables Haml as the templating engine for you, so you don't have to screw around in your own application.rb when your Gemfile already clearly indicated what templating engine you have installed. Hurrah."
12
+ s.description = "Haml-rails provides Haml generators for Rails 5.1 and above. It also enables Haml as the templating engine for you, so you don't have to screw around in your own application.rb when your Gemfile already clearly indicated what templating engine you have installed. Hurrah."
13
13
  s.licenses = ["MIT"]
14
14
 
15
+ s.metadata = { "rubygems_mfa_required" => "true" }
16
+
15
17
  s.required_rubygems_version = ">= 2.0.0"
16
18
  s.required_ruby_version = ">= 2.3.0"
17
19
 
@@ -24,7 +26,6 @@ Gem::Specification.new do |s|
24
26
  s.add_development_dependency "rails", [">= 5.1"]
25
27
  s.add_development_dependency "bundler"
26
28
  s.add_development_dependency "rake"
27
- s.add_development_dependency 'appraisal'
28
29
 
29
30
  s.files = `git ls-files`.split("\n")
30
31
  s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators/erb/controller/controller_generator'
2
4
 
3
5
  module Haml
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators/erb/mailer/mailer_generator'
2
4
 
3
5
  module Haml
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators/erb/scaffold/scaffold_generator'
2
4
 
3
5
  module Haml
@@ -5,31 +7,44 @@ module Haml
5
7
  class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
6
8
  source_root File.expand_path("../templates", __FILE__)
7
9
 
10
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
11
+
12
+ hook_for :form_builder, :as => :scaffold
13
+
8
14
  def copy_view_files
9
15
  available_views.each do |view|
10
- filename = filename_with_extensions(view)
11
- template "#{view}.html.haml", File.join("app/views", controller_file_path, filename)
12
- end
13
- end
16
+ next if (view == '_form') && !options[:form_builder].nil?
14
17
 
15
- hook_for :form_builder, :as => :scaffold
18
+ template_filename = find_template_for_rails_version view
19
+ filename = filename_with_extensions view
16
20
 
17
- def copy_form_file
18
- if options[:form_builder].nil?
19
- filename = filename_with_extensions("_form")
20
- template "_form.html.haml", File.join("app/views", controller_file_path, filename)
21
+ template template_filename, File.join('app/views', controller_file_path, filename)
22
+ end
23
+
24
+ if ::Rails::VERSION::MAJOR >= 7
25
+ template find_template_for_rails_version('partial'), File.join('app/views', controller_file_path, "_#{singular_name}.html.haml")
21
26
  end
22
27
  end
23
28
 
24
29
  private
25
30
 
26
31
  def available_views
27
- %w(index edit show new)
32
+ %w(index edit show new _form)
28
33
  end
29
34
 
30
35
  def handler
31
36
  :haml
32
37
  end
38
+
39
+ def find_template_for_rails_version(view)
40
+ find_in_source_paths "#{rails_version}/#{view}.html.haml"
41
+ rescue Thor::Error
42
+ "#{view}.html.haml"
43
+ end
44
+
45
+ def rails_version
46
+ @rails_version ||= "#{::Rails::VERSION::MAJOR}_#{::Rails::VERSION::MINOR}"
47
+ end
33
48
  end
34
49
  end
35
50
  end
@@ -0,0 +1,26 @@
1
+ = form_with(model: <%= singular_table_name %>, local: true) do |form|
2
+ - if <%= singular_table_name %>.errors.any?
3
+ %div{id: "error_explanation"}
4
+ %h2= "#{pluralize(<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
5
+
6
+ %ul
7
+ - <%= singular_table_name %>.errors.full_messages.each do |message|
8
+ %li= message
9
+
10
+ <% attributes.each do |attribute| -%>
11
+ %div{class: "field"}
12
+ <% if attribute.password_digest? -%>
13
+ = form.label :password
14
+ = form.password_field :password, id: :<%= field_id(:password) %>
15
+
16
+ %div{class: "field"}
17
+ = form.label :password_confirmation
18
+ = form.password_field :password_confirmation, id: :<%= field_id(:password_confirmation) %>
19
+ <% else -%>
20
+ = form.label :<%= attribute.column_name %>
21
+ = form.<%= attribute.field_type %> :<%= attribute.column_name %>, id: :<%= field_id(attribute.column_name) %>
22
+ <% end -%>
23
+
24
+ <% end -%>
25
+ %div{class: "actions"}
26
+ = form.submit
@@ -0,0 +1,7 @@
1
+ %h1 Editing <%= singular_table_name.titleize %>
2
+
3
+ = render 'form', <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ = link_to 'Show', @<%= singular_table_name %>
6
+ |
7
+ = link_to 'Back', <%= index_helper %>_path
@@ -0,0 +1,25 @@
1
+ %p{id: "notice"}= notice
2
+
3
+ %h1 <%= plural_table_name.titleize %>
4
+
5
+ %table
6
+ %thead
7
+ %tr
8
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
9
+ %th <%= attribute.human_name %>
10
+ <% end -%>
11
+ %th{colspan: "3"}
12
+
13
+ %tbody
14
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
15
+ %tr
16
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
17
+ %td= <%= singular_table_name %>.<%= attribute.name %>
18
+ <% end -%>
19
+ %td= link_to 'Show', <%= singular_table_name %>
20
+ %td= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>)
21
+ %td= link_to 'Destroy', <%= singular_table_name %>, method: :delete, data: { confirm: 'Are you sure?' }
22
+
23
+ %br
24
+
25
+ = link_to 'New <%= singular_table_name.titleize %>', new_<%= singular_table_name %>_path
@@ -0,0 +1,5 @@
1
+ %h1 New <%= singular_table_name.titleize %>
2
+
3
+ = render 'form', <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ = link_to 'Back', <%= index_helper %>_path
@@ -0,0 +1,11 @@
1
+ %p{id: "notice"}= notice
2
+
3
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
4
+ %p
5
+ %strong <%= attribute.human_name %>:
6
+ = @<%= singular_table_name %>.<%= attribute.name %>
7
+
8
+ <% end -%>
9
+ = link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>)
10
+ |
11
+ = link_to 'Back', <%= index_helper %>_path
@@ -0,0 +1,26 @@
1
+ = form_with(model: <%= model_resource_name %>, local: true) do |form|
2
+ - if <%= singular_table_name %>.errors.any?
3
+ %div{id: "error_explanation"}
4
+ %h2= "#{pluralize(<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
5
+
6
+ %ul
7
+ - <%= singular_table_name %>.errors.full_messages.each do |message|
8
+ %li= message
9
+
10
+ <% attributes.each do |attribute| -%>
11
+ %div{class: "field"}
12
+ <% if attribute.password_digest? -%>
13
+ = form.label :password
14
+ = form.password_field :password
15
+
16
+ %div{class: "field"}
17
+ = form.label :password_confirmation
18
+ = form.password_field :password_confirmation
19
+ <% else -%>
20
+ = form.label :<%= attribute.column_name %>
21
+ = form.<%= attribute.field_type %> :<%= attribute.column_name %>
22
+ <% end -%>
23
+
24
+ <% end -%>
25
+ %div{class: "actions"}
26
+ = form.submit
@@ -0,0 +1,7 @@
1
+ %h1 Editing <%= singular_table_name.titleize %>
2
+
3
+ = render 'form', <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ = link_to 'Show', @<%= singular_table_name %>
6
+ |
7
+ = link_to 'Back', <%= index_helper %>_path
@@ -0,0 +1,25 @@
1
+ %p{id: "notice"}= notice
2
+
3
+ %h1 <%= plural_table_name.titleize %>
4
+
5
+ %table
6
+ %thead
7
+ %tr
8
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
9
+ %th <%= attribute.human_name %>
10
+ <% end -%>
11
+ %th{colspan: "3"}
12
+
13
+ %tbody
14
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
15
+ %tr
16
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
17
+ %td= <%= singular_table_name %>.<%= attribute.name %>
18
+ <% end -%>
19
+ %td= link_to 'Show', <%= model_resource_name %>
20
+ %td= link_to 'Edit', edit_<%= singular_route_name %>_path(<%= singular_table_name %>)
21
+ %td= link_to 'Destroy', <%= model_resource_name %>, method: :delete, data: { confirm: 'Are you sure?' }
22
+
23
+ %br
24
+
25
+ = link_to 'New <%= singular_table_name.titleize %>', new_<%= singular_route_name %>_path
@@ -0,0 +1,5 @@
1
+ %h1 New <%= singular_table_name.titleize %>
2
+
3
+ = render 'form', <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ = link_to 'Back', <%= index_helper %>_path
@@ -0,0 +1,11 @@
1
+ %p{id: "notice"}= notice
2
+
3
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
4
+ %p
5
+ %strong <%= attribute.human_name %>:
6
+ = @<%= singular_table_name %>.<%= attribute.name %>
7
+
8
+ <% end -%>
9
+ = link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>)
10
+ |
11
+ = link_to 'Back', <%= index_helper %>_path
@@ -0,0 +1,29 @@
1
+ = form_with(model: <%= model_resource_name %>, local: true) do |form|
2
+ - if <%= singular_table_name %>.errors.any?
3
+ %div{id: "error_explanation"}
4
+ %h2= "#{pluralize(<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
5
+
6
+ %ul
7
+ - <%= singular_table_name %>.errors.full_messages.each do |message|
8
+ %li= message
9
+
10
+ <% attributes.each do |attribute| -%>
11
+ %div{class: "field"}
12
+ <% if attribute.password_digest? -%>
13
+ = form.label :password
14
+ = form.password_field :password
15
+
16
+ %div{class: "field"}
17
+ = form.label :password_confirmation
18
+ = form.password_field :password_confirmation
19
+ <% elsif attribute.attachments? -%>
20
+ = form.label :<%= attribute.column_name %>
21
+ = form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true
22
+ <% else -%>
23
+ = form.label :<%= attribute.column_name %>
24
+ = form.<%= attribute.field_type %> :<%= attribute.column_name %>
25
+ <% end -%>
26
+
27
+ <% end -%>
28
+ %div{class: "actions"}
29
+ = form.submit
@@ -0,0 +1,7 @@
1
+ %h1 Editing <%= singular_table_name.titleize %>
2
+
3
+ = render 'form', <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ = link_to 'Show', @<%= singular_table_name %>
6
+ |
7
+ = link_to 'Back', <%= index_helper %>_path
@@ -0,0 +1,25 @@
1
+ %p{id: "notice"}= notice
2
+
3
+ %h1 <%= plural_table_name.titleize %>
4
+
5
+ %table
6
+ %thead
7
+ %tr
8
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
9
+ %th <%= attribute.human_name %>
10
+ <% end -%>
11
+ %th{colspan: "3"}
12
+
13
+ %tbody
14
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
15
+ %tr
16
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
17
+ %td= <%= singular_table_name %>.<%= attribute.column_name %>
18
+ <% end -%>
19
+ %td= link_to 'Show', <%= model_resource_name %>
20
+ %td= link_to 'Edit', edit_<%= singular_route_name %>_path(<%= singular_table_name %>)
21
+ %td= link_to 'Destroy', <%= model_resource_name %>, method: :delete, data: { confirm: 'Are you sure?' }
22
+
23
+ %br
24
+
25
+ = link_to 'New <%= singular_table_name.titleize %>', new_<%= singular_route_name %>_path
@@ -0,0 +1,5 @@
1
+ %h1 New <%= singular_table_name.titleize %>
2
+
3
+ = render 'form', <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ = link_to 'Back', <%= index_helper %>_path
@@ -0,0 +1,18 @@
1
+ %p{id: "notice"}= notice
2
+
3
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
4
+ %p
5
+ %strong <%= attribute.human_name %>:
6
+ <% if attribute.attachment? -%>
7
+ = link_to @<%= singular_table_name %>.<%= attribute.column_name %>.filename, @<%= singular_table_name %>.<%= attribute.column_name %> if @<%= singular_table_name %>.<%= attribute.column_name %>.attached?
8
+ <% elsif attribute.attachments? -%>
9
+ - @<%= singular_table_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>|
10
+ %div= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %>
11
+ <% else -%>
12
+ = @<%= singular_table_name %>.<%= attribute.column_name %>
13
+ <% end -%>
14
+
15
+ <% end -%>
16
+ = link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>)
17
+ |
18
+ = link_to 'Back', <%= index_helper %>_path
@@ -0,0 +1,29 @@
1
+ = form_with(model: <%= model_resource_name %>) do |form|
2
+ - if <%= singular_table_name %>.errors.any?
3
+ %div{id: "error_explanation"}
4
+ %h2= "#{pluralize(<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
5
+
6
+ %ul
7
+ - <%= singular_table_name %>.errors.each do |error|
8
+ %li= error.full_message
9
+
10
+ <% attributes.each do |attribute| -%>
11
+ %div{class: "field"}
12
+ <% if attribute.password_digest? -%>
13
+ = form.label :password
14
+ = form.password_field :password
15
+
16
+ %div{class: "field"}
17
+ = form.label :password_confirmation
18
+ = form.password_field :password_confirmation
19
+ <% elsif attribute.attachments? -%>
20
+ = form.label :<%= attribute.column_name %>
21
+ = form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true
22
+ <% else -%>
23
+ = form.label :<%= attribute.column_name %>
24
+ = form.<%= attribute.field_type %> :<%= attribute.column_name %>
25
+ <% end -%>
26
+
27
+ <% end -%>
28
+ %div{class: "actions"}
29
+ = form.submit
@@ -0,0 +1,7 @@
1
+ %h1 Editing <%= singular_table_name.titleize %>
2
+
3
+ = render 'form', <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ = link_to 'Show', @<%= singular_table_name %>
6
+ |
7
+ = link_to 'Back', <%= index_helper %>_path
@@ -0,0 +1,25 @@
1
+ %p{id: "notice"}= notice
2
+
3
+ %h1 <%= plural_table_name.titleize %>
4
+
5
+ %table
6
+ %thead
7
+ %tr
8
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
9
+ %th <%= attribute.human_name %>
10
+ <% end -%>
11
+ %th{colspan: "3"}
12
+
13
+ %tbody
14
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
15
+ %tr
16
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
17
+ %td= <%= singular_table_name %>.<%= attribute.column_name %>
18
+ <% end -%>
19
+ %td= link_to 'Show', <%= model_resource_name %>
20
+ %td= link_to 'Edit', edit_<%= singular_route_name %>_path(<%= singular_table_name %>)
21
+ %td= link_to 'Destroy', <%= model_resource_name %>, method: :delete, data: { confirm: 'Are you sure?' }
22
+
23
+ %br
24
+
25
+ = link_to 'New <%= singular_table_name.titleize %>', new_<%= singular_route_name %>_path
@@ -0,0 +1,5 @@
1
+ %h1 New <%= singular_table_name.titleize %>
2
+
3
+ = render 'form', <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ = link_to 'Back', <%= index_helper %>_path
@@ -0,0 +1,18 @@
1
+ %p{id: "notice"}= notice
2
+
3
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
4
+ %p
5
+ %strong <%= attribute.human_name %>:
6
+ <% if attribute.attachment? -%>
7
+ = link_to @<%= singular_table_name %>.<%= attribute.column_name %>.filename, @<%= singular_table_name %>.<%= attribute.column_name %> if @<%= singular_table_name %>.<%= attribute.column_name %>.attached?
8
+ <% elsif attribute.attachments? -%>
9
+ - @<%= singular_table_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>|
10
+ %div= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %>
11
+ <% else -%>
12
+ = @<%= singular_table_name %>.<%= attribute.column_name %>
13
+ <% end -%>
14
+
15
+ <% end -%>
16
+ = link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>)
17
+ |
18
+ = link_to 'Back', <%= index_helper %>_path
@@ -0,0 +1,29 @@
1
+ = form_with(model: <%= model_resource_name %>) do |form|
2
+ - if <%= singular_table_name %>.errors.any?
3
+ %div{style: "color: red"}
4
+ %h2= "#{pluralize(<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
5
+
6
+ %ul
7
+ - <%= singular_table_name %>.errors.each do |error|
8
+ %li= error.full_message
9
+
10
+ <% attributes.each do |attribute| -%>
11
+ %div
12
+ <% if attribute.password_digest? -%>
13
+ = form.label :password, style: "display: block"
14
+ = form.password_field :password
15
+
16
+ %div
17
+ = form.label :password_confirmation, style: "display: block"
18
+ = form.password_field :password_confirmation
19
+ <% elsif attribute.attachments? -%>
20
+ = form.label :<%= attribute.column_name %>, style: "display: block"
21
+ = form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true
22
+ <% else -%>
23
+ = form.label :<%= attribute.column_name %>, style: "display: block"
24
+ = form.<%= attribute.field_type %> :<%= attribute.column_name %>
25
+ <% end -%>
26
+
27
+ <% end -%>
28
+ %div
29
+ = form.submit
@@ -0,0 +1,10 @@
1
+ %h1 Editing <%= human_name.downcase %>
2
+
3
+ = render "form", <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ %br
6
+
7
+ %div
8
+ = link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>
9
+ |
10
+ = link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>