haml-rails 2.0.1 → 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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +83 -0
  3. data/.gitignore +1 -0
  4. data/Gemfile +17 -2
  5. data/README.md +14 -5
  6. data/haml-rails.gemspec +8 -8
  7. data/lib/generators/haml/controller/controller_generator.rb +3 -2
  8. data/lib/generators/haml/mailer/mailer_generator.rb +7 -33
  9. data/lib/generators/haml/scaffold/scaffold_generator.rb +25 -11
  10. data/lib/generators/haml/scaffold/templates/5_1/_form.html.haml +26 -0
  11. data/lib/generators/haml/scaffold/templates/5_1/edit.html.haml +7 -0
  12. data/lib/generators/haml/scaffold/templates/5_1/index.html.haml +25 -0
  13. data/lib/generators/haml/scaffold/templates/5_1/new.html.haml +5 -0
  14. data/lib/generators/haml/scaffold/templates/5_1/show.html.haml +11 -0
  15. data/lib/generators/haml/scaffold/templates/5_2/_form.html.haml +26 -0
  16. data/lib/generators/haml/scaffold/templates/5_2/edit.html.haml +7 -0
  17. data/lib/generators/haml/scaffold/templates/5_2/index.html.haml +25 -0
  18. data/lib/generators/haml/scaffold/templates/5_2/new.html.haml +5 -0
  19. data/lib/generators/haml/scaffold/templates/5_2/show.html.haml +11 -0
  20. data/lib/generators/haml/scaffold/templates/6_0/_form.html.haml +29 -0
  21. data/lib/generators/haml/scaffold/templates/6_0/edit.html.haml +7 -0
  22. data/lib/generators/haml/scaffold/templates/6_0/index.html.haml +25 -0
  23. data/lib/generators/haml/scaffold/templates/6_0/new.html.haml +5 -0
  24. data/lib/generators/haml/scaffold/templates/6_0/show.html.haml +18 -0
  25. data/lib/generators/haml/scaffold/templates/6_1/_form.html.haml +29 -0
  26. data/lib/generators/haml/scaffold/templates/6_1/edit.html.haml +7 -0
  27. data/lib/generators/haml/scaffold/templates/6_1/index.html.haml +25 -0
  28. data/lib/generators/haml/scaffold/templates/6_1/new.html.haml +5 -0
  29. data/lib/generators/haml/scaffold/templates/6_1/show.html.haml +18 -0
  30. data/lib/generators/haml/scaffold/templates/7_0/_form.html.haml +29 -0
  31. data/lib/generators/haml/scaffold/templates/7_0/edit.html.haml +10 -0
  32. data/lib/generators/haml/scaffold/templates/7_0/index.html.haml +11 -0
  33. data/lib/generators/haml/scaffold/templates/7_0/new.html.haml +8 -0
  34. data/lib/generators/haml/scaffold/templates/7_0/partial.html.haml +14 -0
  35. data/lib/generators/haml/scaffold/templates/7_0/show.html.haml +10 -0
  36. data/lib/generators/haml/scaffold/templates/7_1 +1 -0
  37. data/lib/generators/haml/scaffold/templates/7_2/_form.html.haml +29 -0
  38. data/lib/generators/haml/scaffold/templates/7_2/edit.html.haml +12 -0
  39. data/lib/generators/haml/scaffold/templates/7_2/index.html.haml +13 -0
  40. data/lib/generators/haml/scaffold/templates/7_2/new.html.haml +10 -0
  41. data/lib/generators/haml/scaffold/templates/7_2/partial.html.haml +14 -0
  42. data/lib/generators/haml/scaffold/templates/7_2/show.html.haml +10 -0
  43. data/lib/generators/haml/scaffold/templates/8_0 +1 -0
  44. data/lib/generators/haml/scaffold/templates/_form.html.haml +1 -0
  45. data/lib/generators/haml/scaffold/templates/edit.html.haml +1 -0
  46. data/lib/generators/haml/scaffold/templates/index.html.haml +1 -0
  47. data/lib/generators/haml/scaffold/templates/new.html.haml +1 -0
  48. data/lib/generators/haml/scaffold/templates/partial.html.haml +1 -0
  49. data/lib/generators/haml/scaffold/templates/show.html.haml +1 -0
  50. data/lib/haml-rails/version.rb +3 -1
  51. data/lib/haml-rails.rb +2 -2
  52. data/lib/rails/generators/haml/application_layout/application_layout_generator.rb +8 -6
  53. data/lib/tasks/erb2haml.rake +22 -18
  54. data/test/fixtures/routes.rb +2 -0
  55. data/test/lib/generators/haml/controller_generator_test.rb +6 -3
  56. data/test/lib/generators/haml/mailer_generator_test.rb +23 -1
  57. data/test/lib/generators/haml/scaffold_generator_test.rb +4 -1
  58. data/test/lib/generators/haml/scaffold_template_contents_test.rb +76 -0
  59. data/test/test_helper.rb +44 -53
  60. metadata +52 -43
  61. data/.travis.yml +0 -23
  62. data/Appraisals +0 -27
  63. data/gemfiles/rails_5_1.gemfile +0 -10
  64. data/gemfiles/rails_5_2.gemfile +0 -10
  65. data/gemfiles/rails_6.beta2.gemfile +0 -10
  66. data/lib/generators/haml/scaffold/templates/_form.html.haml +0 -15
  67. data/lib/generators/haml/scaffold/templates/edit.html.haml +0 -7
  68. data/lib/generators/haml/scaffold/templates/index.html.haml +0 -25
  69. data/lib/generators/haml/scaffold/templates/new.html.haml +0 -5
  70. data/lib/generators/haml/scaffold/templates/show.html.haml +0 -11
  71. data/test/lib/generators/haml/testing_helper.rb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aabd39031775035905df0e25dc366c5d23136d548ebe418e160e18c4d488a9da
4
- data.tar.gz: 12698b8d07d1b31d5393fa3b2d559681f81685dcf59cede01d5b5b5953cf143b
3
+ metadata.gz: 675edf6edfcd12cf4e411bd43aca9143cd4ae8f0597ab5235e4ebb65fae5e4e0
4
+ data.tar.gz: 21e1357af940ed0d8c70bc561393920389547ee68d8bb319c1bfba4484343d94
5
5
  SHA512:
6
- metadata.gz: 21fc8f09ee72b62aa3f36cb4199c19aaeea94fb57aed8715cb8aef115710010edff6ea09a8fda3bdbd36a1eb1a281ad9079eb42ee190f9aec2d31a2a33c94179
7
- data.tar.gz: 033700067b79242c2286760861dd6d3f440992561dfd08d4485c7392588a6e90408fbc5ae6c5dabfd8a0c77f8368d5f900883982f51686062dde41d86b1063db
6
+ metadata.gz: 75f63d2c53a4a6caaa9f8bbdfd94f629602ea13755aa085e1a30c6dff5306129e21e7ac95b3caf51d5cdd189f971c754ceb144b50a924a89b8861ee5aafab57b
7
+ data.tar.gz: 15fb9334379933441817672433b2186e1e1a3e6eb079927b42cd6807cea227eb71bbaad2f45231dd9c3ab1d41e10f8dec8b3a9ad27bcf73edbe4084b3aa2f3c6
@@ -0,0 +1,83 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version:
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'
26
+
27
+ include:
28
+ - ruby-version: '3.1'
29
+ rails-version: '6.0'
30
+
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'
61
+
62
+ - ruby-version: jruby
63
+ rails-version: '6.1'
64
+
65
+ exclude:
66
+ - ruby-version: '3.1'
67
+ rails-version: '8.0'
68
+
69
+ env:
70
+ RUBY_VERSION: ${{ matrix.ruby-version }}
71
+ RAILS_VERSION: ${{ matrix.rails-version }}
72
+ steps:
73
+ - uses: actions/checkout@v5
74
+ - name: Set up Ruby
75
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
76
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
77
+ uses: ruby/setup-ruby@v1
78
+ # uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
79
+ with:
80
+ ruby-version: ${{ matrix.ruby-version }}
81
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
82
+ - name: Run tests
83
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -4,3 +4,4 @@
4
4
  gemfiles/*.lock
5
5
  tmp/
6
6
  /vendor/bundle
7
+ log
data/Gemfile CHANGED
@@ -3,6 +3,21 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in haml-rails.gemspec
4
4
  gemspec
5
5
 
6
- gem 'rubysl', '~> 2.0', platforms: :rbx
7
- gem 'minitest', platforms: :rbx
8
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/indirect/haml-rails.svg)](https://travis-ci.org/indirect/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 4. 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.
@@ -47,9 +52,13 @@ false will also not prompt, however, will leave the .erb files intact.
47
52
 
48
53
  ### Older versions of Rails
49
54
 
50
- The current version of Haml-rails requires 4.0.1 or later.
55
+ The current version of Haml-rails requires Rails 5.1 or later.
56
+
57
+ Haml-rails version 1.0.0 is the last version to support Rails 4. To use it, add this line to your Gemfile:
58
+
59
+ gem "haml-rails", "~> 1.0.0"
51
60
 
52
- Haml-rails version 0.4 is the last version to support Rails 3. To use it, add this line to your Gemfile:
61
+ For Rails 3, use haml-rails version 0.4 by adding this line to your Gemfile instead:
53
62
 
54
63
  gem "haml-rails", "~> 0.4.0"
55
64
 
data/haml-rails.gemspec CHANGED
@@ -7,25 +7,25 @@ Gem::Specification.new do |s|
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["André Arko"]
9
9
  s.email = ["andre@arko.net"]
10
- s.homepage = "https://github.com/indirect/haml-rails"
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 4. 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.rubyforge_project = "haml-rails"
15
+ s.metadata = { "rubygems_mfa_required" => "true" }
16
+
16
17
  s.required_rubygems_version = ">= 2.0.0"
17
18
  s.required_ruby_version = ">= 2.3.0"
18
19
 
19
- s.add_dependency "haml", [">= 4.0.6", "< 6.0"]
20
+ s.add_dependency "haml", [">= 4.0.6"]
20
21
  s.add_dependency "activesupport", [">= 5.1"]
21
22
  s.add_dependency "actionpack", [">= 5.1"]
22
23
  s.add_dependency "railties", [">= 5.1"]
23
- s.add_dependency "html2haml", [">= 1.0.1"]
24
-
24
+
25
+ s.add_development_dependency "html2haml", [">= 1.0.1"]
25
26
  s.add_development_dependency "rails", [">= 5.1"]
26
- s.add_development_dependency "bundler", "~> 2.0"
27
+ s.add_development_dependency "bundler"
27
28
  s.add_development_dependency "rake"
28
- s.add_development_dependency 'appraisal', '~> 1.0'
29
29
 
30
30
  s.files = `git ls-files`.split("\n")
31
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
@@ -5,12 +7,11 @@ module Haml
5
7
  class ControllerGenerator < Erb::Generators::ControllerGenerator
6
8
  source_root File.expand_path("../templates", __FILE__)
7
9
 
8
- protected
10
+ private
9
11
 
10
12
  def handler
11
13
  :haml
12
14
  end
13
-
14
15
  end
15
16
  end
16
17
  end
@@ -1,42 +1,16 @@
1
- require 'generators/haml/controller/controller_generator'
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators/erb/mailer/mailer_generator'
2
4
 
3
5
  module Haml
4
6
  module Generators
5
- class MailerGenerator < ControllerGenerator
7
+ class MailerGenerator < Erb::Generators::MailerGenerator
6
8
  source_root File.expand_path("../templates", __FILE__)
7
9
 
8
- def copy_view_files
9
- if ::Rails.version.to_s >= "4.2.0"
10
- view_base_path = File.join("app/views", class_path, file_name + "_mailer")
11
- empty_directory view_base_path
12
-
13
- if behavior == :invoke
14
- formats.each do |format|
15
- layout_path = File.join("app/views/layouts", class_path, filename_with_extensions("mailer", format))
16
- template filename_with_extensions(:layout, format), layout_path unless File.exist?(layout_path)
17
- end
18
- end
19
-
20
- actions.each do |action|
21
- @action = action
22
-
23
- formats.each do |format|
24
- @path = File.join(view_base_path, filename_with_extensions(action, format))
25
- template filename_with_extensions(:view, format), @path
26
- end
27
- end
28
- else
29
- super
30
- end
31
- end
32
-
33
- protected
34
- def format
35
- :text
36
- end
10
+ private
37
11
 
38
- def formats
39
- [:text, :html]
12
+ def handler
13
+ :haml
40
14
  end
41
15
  end
42
16
  end
@@ -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,32 +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
20
+
21
+ template template_filename, File.join('app/views', controller_file_path, filename)
22
+ end
16
23
 
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)
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
- protected
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
33
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
34
48
  end
35
49
  end
36
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