draft_generators 0.0.3 → 0.0.4

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 (27) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/VERSION +1 -1
  4. data/draft_generators.gemspec +21 -20
  5. data/lib/draft_generators.rb +1 -0
  6. data/lib/generators/draft/account/account_generator.rb +189 -0
  7. data/lib/generators/draft/account/templates/controllers/authentication_controller.rb +96 -0
  8. data/lib/generators/draft/account/templates/views/authentication/edit_profile.html.erb +38 -0
  9. data/lib/generators/draft/account/templates/views/authentication/edit_profile_with_errors.html.erb +44 -0
  10. data/lib/generators/draft/account/templates/views/authentication/sign_in.html.erb +23 -0
  11. data/lib/generators/draft/account/templates/views/authentication/sign_up.html.erb +43 -0
  12. data/lib/generators/draft/layout/layout_generator.rb +3 -3
  13. data/lib/generators/draft/layout/templates/_cdn_assets.html.erb +13 -0
  14. data/lib/generators/draft/layout/templates/_navbar.html.erb +1 -1
  15. data/lib/generators/draft/layout/templates/layout.html.erb +13 -12
  16. data/lib/generators/draft/resource/resource_generator.rb +19 -17
  17. data/lib/generators/draft/resource/templates/controllers/controller.rb +45 -44
  18. data/lib/generators/draft/resource/templates/controllers/read_only_controller.rb +2 -2
  19. data/lib/generators/draft/resource/templates/views/association_new_form.html.erb +6 -6
  20. data/lib/generators/draft/resource/templates/views/edit_form.html.erb +7 -7
  21. data/lib/generators/draft/resource/templates/views/edit_form_with_errors.html.erb +8 -8
  22. data/lib/generators/draft/resource/templates/views/index.html.erb +69 -23
  23. data/lib/generators/draft/resource/templates/views/new_form.html.erb +7 -7
  24. data/lib/generators/draft/resource/templates/views/new_form_with_errors.html.erb +8 -8
  25. data/lib/generators/draft/resource/templates/views/show.html.erb +65 -25
  26. metadata +24 -5
  27. data/lib/generators/draft/layout/templates/_bootstrapcdn_assets.html.erb +0 -10
@@ -1,3 +1,5 @@
1
+ require 'indefinite_article'
2
+
1
3
  module Draft
2
4
  class ResourceGenerator < Rails::Generators::NamedBase
3
5
  source_root File.expand_path("../templates", __FILE__)
@@ -30,13 +32,13 @@ module Draft
30
32
  end
31
33
 
32
34
  def create_root_folder
33
- empty_directory File.join("app/views", "#{singular_table_name}_templates")
35
+ empty_directory File.join("app/views", "#{plural_table_name}")
34
36
  end
35
37
 
36
38
  def generate_view_files
37
39
  available_views.each do |view|
38
40
  filename = view_filename_with_extensions(view)
39
- template filename, File.join("app/views", "#{singular_table_name}_templates", File.basename(options[:new_form_name].presence || filename))
41
+ template filename, File.join("app/views", "#{plural_table_name}", File.basename(options[:new_form_name].presence || filename))
40
42
  end
41
43
  end
42
44
 
@@ -46,7 +48,7 @@ module Draft
46
48
  if read_only?
47
49
  read_only_routes
48
50
  else
49
- golden_seven_routes
51
+ golden_five_routes
50
52
  end
51
53
  end
52
54
 
@@ -61,7 +63,7 @@ module Draft
61
63
 
62
64
  private
63
65
 
64
- def golden_seven_routes
66
+ def golden_five_routes
65
67
  log :route, "RESTful routes"
66
68
 
67
69
  route <<-RUBY.gsub(/^ /, "")
@@ -69,19 +71,19 @@ module Draft
69
71
  # Routes for the #{singular_table_name.humanize} resource:
70
72
 
71
73
  # CREATE
72
- get("/#{plural_table_name}/new", { :controller => "#{plural_table_name}", :action => "new_form" })
73
- #{skip_post? ? "get" : "post"}("/create_#{singular_table_name}", { :controller => "#{plural_table_name}", :action => "create_row" })
74
-
74
+ post("/insert_#{singular_table_name}", { :controller => "#{plural_table_name}", :action => "create" })
75
+
75
76
  # READ
76
77
  get("/#{plural_table_name}", { :controller => "#{plural_table_name}", :action => "index" })
77
- get("/#{plural_table_name}/:id_to_display", { :controller => "#{plural_table_name}", :action => "show" })
78
-
78
+
79
+ get("/#{plural_table_name}/:path_id", { :controller => "#{plural_table_name}", :action => "show" })
80
+
79
81
  # UPDATE
80
- get("/#{plural_table_name}/:prefill_with_id/edit", { :controller => "#{plural_table_name}", :action => "edit_form" })
81
- #{skip_post? ? "get" : "post"}("/update_#{singular_table_name}/:id_to_modify", { :controller => "#{plural_table_name}", :action => "update_row" })
82
-
82
+
83
+ post("/modify_#{singular_table_name}/:path_id", { :controller => "#{plural_table_name}", :action => "update" })
84
+
83
85
  # DELETE
84
- get("/delete_#{singular_table_name}/:id_to_remove", { :controller => "#{plural_table_name}", :action => "destroy_row" })
86
+ get("/delete_#{singular_table_name}/:path_id", { :controller => "#{plural_table_name}", :action => "destroy" })
85
87
 
86
88
  #------------------------------
87
89
  RUBY
@@ -95,9 +97,9 @@ module Draft
95
97
  # Routes for the #{singular_table_name.humanize} resource:
96
98
 
97
99
  # READ
98
- get("/#{plural_table_name}", { :controller => "#{plural_table_name}", :action => "index" })
99
- get("/#{plural_table_name}/:id_to_display", { :controller => "#{plural_table_name}", :action => "show" })
100
-
100
+ get("/#{plural_table_name}", { :controller => "#{plural_table_name}", :action => "index", :via => "get"})
101
+ get("/#{plural_table_name}/:path_id", { :controller => "#{plural_table_name}", :action => "show", :via => "get"})
102
+
101
103
  #------------------------------
102
104
  RUBY
103
105
  end
@@ -158,7 +160,7 @@ module Draft
158
160
  elsif only_new_form?
159
161
  %w(association_new_form)
160
162
  else
161
- %w(index new_form new_form_with_errors edit_form edit_form_with_errors show)
163
+ %w(index show)
162
164
  end
163
165
  end
164
166
 
@@ -1,96 +1,97 @@
1
1
  class <%= plural_table_name.camelize %>Controller < ApplicationController
2
2
  def index
3
- @<%= plural_table_name.underscore %> = <%= class_name.singularize %>.all
3
+ matching_<%= plural_table_name.underscore %> = <%= class_name.singularize %>.all
4
4
 
5
- render("<%= singular_table_name.underscore %>_templates/index.html.erb")
5
+ @list_of_<%= plural_table_name.underscore %> = matching_<%= plural_table_name.underscore %>.order({ :created_at => :desc })
6
+
7
+ render({ :template => "<%= plural_table_name.underscore %>/index" })
6
8
  end
7
9
 
8
10
  def show
9
- @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params.fetch("id_to_display"))
11
+ the_id = params.fetch("path_id")
10
12
 
11
- render("<%= singular_table_name.underscore %>_templates/show.html.erb")
12
- end
13
+ matching_<%= plural_table_name.underscore.downcase %> = <%= class_name.singularize %>.where({ :id => the_id })
13
14
 
14
- def new_form
15
- @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.new
15
+ @the_<%= singular_table_name.underscore %> = matching_<%= plural_table_name.underscore.downcase %>.at(0)
16
16
 
17
- render("<%= singular_table_name.underscore %>_templates/new_form.html.erb")
17
+ render({ :template => "<%= plural_table_name.underscore %>/show" })
18
18
  end
19
19
 
20
- def create_row
21
- @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.new
22
-
20
+ def create
21
+ the_<%= singular_table_name.underscore %> = <%= class_name.singularize %>.new
23
22
  <% attributes.each do |attribute| -%>
24
- @<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params.fetch("<%= attribute.column_name %>")
23
+ <% if attribute.field_type == :check_box -%>
24
+ the_<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params.fetch("query_<%= attribute.column_name %>", false)
25
+ <% else -%>
26
+ the_<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params.fetch("query_<%= attribute.column_name %>")
27
+ <% end -%>
25
28
  <% end -%>
26
29
 
27
30
  <% unless skip_validation_alerts? -%>
28
- if @<%= singular_table_name.underscore %>.valid?
29
- @<%= singular_table_name.underscore %>.save
30
-
31
- redirect_back(:fallback_location => "/<%= @plural_table_name.underscore %>", :notice => "<%= singular_table_name.humanize %> created successfully.")
31
+ if the_<%= singular_table_name.underscore %>.valid?
32
+ the_<%= singular_table_name.underscore %>.save
33
+ redirect_to("/<%= plural_table_name.underscore %>", { :notice => "<%= singular_table_name.humanize %> created successfully." })
32
34
  else
33
- render("<%= singular_table_name.underscore %>_templates/new_form_with_errors.html.erb")
35
+ redirect_to("/<%= plural_table_name.underscore %>", { :alert => the_<%= singular_table_name.underscore %>.errors.full_messages.to_sentence })
34
36
  end
35
37
  <% else -%>
36
- @<%= singular_table_name.underscore %>.save
38
+ the_<%= singular_table_name.underscore %>.save
37
39
 
38
40
  <% unless skip_redirect? -%>
39
41
  redirect_to("/<%= @plural_table_name.underscore %>")
40
42
  <% else -%>
41
43
  @current_count = <%= class_name.singularize %>.count
42
44
 
43
- render("<%= singular_table_name.underscore %>_templates/create_row.html.erb")
45
+ render("<%= singular_table_name.underscore %>_templates/create_row")
44
46
  <% end -%>
45
47
  <% end -%>
46
48
  end
47
49
 
48
- def edit_form
49
- @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params.fetch("prefill_with_id"))
50
-
51
- render("<%= singular_table_name.underscore %>_templates/edit_form.html.erb")
52
- end
53
-
54
- def update_row
55
- @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params.fetch("id_to_modify"))
50
+ def update
51
+ the_id = params.fetch("path_id")
52
+ the_<%= singular_table_name.underscore %> = <%= class_name.singularize %>.where({ :id => the_id }).at(0)
56
53
 
57
54
  <% attributes.each do |attribute| -%>
58
- @<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params.fetch("<%= attribute.column_name %>")
55
+ <% if attribute.field_type == :check_box -%>
56
+ the_<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params.fetch("query_<%= attribute.column_name %>", false)
57
+ <% else -%>
58
+ the_<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params.fetch("query_<%= attribute.column_name %>")
59
+ <% end -%>
59
60
  <% end -%>
60
61
 
61
62
  <% unless skip_validation_alerts? -%>
62
- if @<%= singular_table_name.underscore %>.valid?
63
- @<%= singular_table_name.underscore %>.save
64
-
65
- redirect_to("/<%= @plural_table_name.underscore %>/#{@<%= singular_table_name.underscore %>.id}", :notice => "<%= singular_table_name.humanize %> updated successfully.")
63
+ if the_<%= singular_table_name.underscore %>.valid?
64
+ the_<%= singular_table_name.underscore %>.save
65
+ redirect_to("/<%= plural_table_name.underscore %>/#{the_<%= singular_table_name.underscore %>.id}", { :notice => "<%= singular_table_name.humanize %> updated successfully."} )
66
66
  else
67
- render("<%= singular_table_name.underscore %>_templates/edit_form_with_errors.html.erb")
67
+ redirect_to("/<%= plural_table_name.underscore %>/#{the_<%= singular_table_name.underscore %>.id}", { :alert => the_<%= singular_table_name.underscore %>.errors.full_messages.to_sentence })
68
68
  end
69
69
  <% else -%>
70
- @<%= singular_table_name.underscore %>.save
70
+ the_<%= singular_table_name.underscore %>.save
71
71
 
72
72
  <% unless skip_redirect? -%>
73
- redirect_to("/<%= @plural_table_name.underscore %>/#{@<%= singular_table_name.underscore %>.id}")
73
+ redirect_to("/<%= plural_table_name.underscore %>/#{the_<%= singular_table_name.underscore %>.id}")
74
74
  <% else -%>
75
- render("<%= singular_table_name.underscore %>_templates/update_row.html.erb")
76
- <% end -%>
75
+ render({ :template => "<%= plural_table_name.underscore %>/show" })
76
+ <% end -%>
77
77
  <% end -%>
78
78
  end
79
79
 
80
- def destroy_row
81
- @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params.fetch("id_to_remove"))
80
+ def destroy
81
+ the_id = params.fetch("path_id")
82
+ the_<%= singular_table_name.underscore %> = <%= class_name.singularize %>.where({ :id => the_id }).at(0)
82
83
 
83
- @<%= singular_table_name.underscore %>.destroy
84
+ the_<%= singular_table_name.underscore %>.destroy
84
85
 
85
86
  <% unless skip_validation_alerts? -%>
86
- redirect_to("/<%= @plural_table_name.underscore %>", :notice => "<%= singular_table_name.humanize %> deleted successfully.")
87
+ redirect_to("/<%= plural_table_name.underscore %>", { :notice => "<%= singular_table_name.humanize %> deleted successfully."} )
87
88
  <% else -%>
88
89
  <% unless skip_redirect? -%>
89
- redirect_to("/<%= @plural_table_name.underscore %>")
90
+ redirect_to("/<%= plural_table_name.underscore %>")
90
91
  <% else -%>
91
92
  @remaining_count = <%= class_name.singularize %>.count
92
-
93
- render("<%= singular_table_name.underscore %>_templates/destroy_row.html.erb")
93
+
94
+ redirect_to("/<%= plural_table_name.underscore %>", { :notice => "<%= singular_table_name.humanize %> deleted successfully."} )
94
95
  <% end -%>
95
96
  <% end -%>
96
97
  end
@@ -2,12 +2,12 @@ class <%= plural_table_name.camelize %>Controller < ApplicationController
2
2
  def index
3
3
  @<%= plural_table_name.underscore %> = <%= class_name.singularize %>.all
4
4
 
5
- render("<%= singular_table_name.underscore %>_templates/index.html.erb")
5
+ render("<%= singular_table_name.underscore %>_templates/index")
6
6
  end
7
7
 
8
8
  def show
9
9
  @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params.fetch("id_to_display"))
10
10
 
11
- render("<%= singular_table_name.underscore %>_templates/show.html.erb")
11
+ render("<%= singular_table_name.underscore %>_templates/show")
12
12
  end
13
13
  end
@@ -19,20 +19,20 @@
19
19
  <!-- Input for <%= attribute.column_name %> end -->
20
20
  <% end -%>
21
21
  <% elsif attribute.field_type == :check_box -%>
22
- <div class="form-group">
22
+ <div>
23
23
  <label for="<%= attribute.column_name %>">
24
24
  <%= attribute.column_name.humanize %>
25
25
  </label>
26
26
  <% if with_sentinels? -%>
27
27
  <!-- Input for <%= attribute.column_name %> start -->
28
28
  <% end -%>
29
- <input id="<%= attribute.column_name %>" class="form-check-input" name="<%= attribute.column_name %>" type="checkbox" <% unless skip_validation_alerts? -%><%%= "checked" if @<%= singular_table_name %>.<%= attribute.column_name %> %><% end -%>>
29
+ <input id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" type="checkbox" <% unless skip_validation_alerts? -%><%%= "checked" if @<%= singular_table_name %>.<%= attribute.column_name %> %><% end -%>>
30
30
  <% if with_sentinels? -%>
31
31
  <!-- Input for <%= attribute.column_name %> end -->
32
32
  <% end -%>
33
33
  </div>
34
34
  <% else -%>
35
- <div class="form-group">
35
+ <div>
36
36
  <label for="<%= attribute.column_name %>">
37
37
  <%= attribute.column_name.humanize %>
38
38
  </label>
@@ -41,7 +41,7 @@
41
41
  <% if with_sentinels? -%>
42
42
  <!-- Input for <%= attribute.column_name %> start -->
43
43
  <% end -%>
44
- <textarea id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" class="form-control" rows="3"><% unless skip_validation_alerts? -%><%%= @<%= singular_table_name %>.<%= attribute.column_name %> %><% end -%></textarea>
44
+ <textarea id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" rows="3"><% unless skip_validation_alerts? -%><%%= @<%= singular_table_name %>.<%= attribute.column_name %> %><% end -%></textarea>
45
45
  <% if with_sentinels? -%>
46
46
  <!-- Input for <%= attribute.column_name %> end -->
47
47
  <% end -%>
@@ -49,7 +49,7 @@
49
49
  <% if with_sentinels? -%>
50
50
  <!-- Input for <%= attribute.column_name %> start -->
51
51
  <% end -%>
52
- <input type="text" id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" class="form-control"<% unless skip_validation_alerts? -%> value="<%%= @<%= singular_table_name %>.<%= attribute.column_name %> %>"<% end -%>>
52
+ <input type="text" id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" <% unless skip_validation_alerts? -%> value="<%%= @<%= singular_table_name %>.<%= attribute.column_name %> %>"<% end -%>>
53
53
  <% if with_sentinels? -%>
54
54
  <!-- Input for <%= attribute.column_name %> end -->
55
55
  <% end -%>
@@ -61,7 +61,7 @@
61
61
  <% end -%>
62
62
 
63
63
  <% end -%>
64
- <button class="btn btn-block btn-outline-secondary">
64
+ <button>
65
65
  Create <%= singular_table_name.humanize.downcase %>
66
66
  </button>
67
67
  </form>
@@ -17,21 +17,21 @@
17
17
  <!-- Label and input for <%= attribute.column_name %> start -->
18
18
  <% end -%>
19
19
  <% if attribute.field_type == :check_box -%>
20
- <div class="form-check">
20
+ <div>
21
21
  <input type="hidden" value="0" name="<%= attribute.column_name %>">
22
22
  <% if with_sentinels? -%>
23
23
  <!-- Input for <%= attribute.column_name %> start -->
24
24
  <% end -%>
25
- <input id="<%= attribute.column_name %>" class="form-check-input" name="<%= attribute.column_name %>" type="checkbox" value="1" <%%= "checked" if @<%= singular_table_name %>.<%= attribute.column_name %> %>>
25
+ <input id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" type="checkbox" value="1" <%%= "checked" if @<%= singular_table_name %>.<%= attribute.column_name %> %>>
26
26
  <% if with_sentinels? -%>
27
27
  <!-- Input for <%= attribute.column_name %> end -->
28
28
  <% end -%>
29
- <label for="<%= attribute.column_name %>" class="form-check-label">
29
+ <label for="<%= attribute.column_name %>">
30
30
  <%= attribute.column_name.humanize %>
31
31
  </label>
32
32
  </div>
33
33
  <% else -%>
34
- <div class="form-group">
34
+ <div>
35
35
  <label for="<%= attribute.column_name %>">
36
36
  <%= attribute.column_name.humanize %>
37
37
  </label>
@@ -40,7 +40,7 @@
40
40
  <% if with_sentinels? -%>
41
41
  <!-- Input for <%= attribute.column_name %> start -->
42
42
  <% end -%>
43
- <textarea id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" class="form-control" rows="3"><%%= @<%= singular_table_name %>.<%= attribute.column_name %> %></textarea>
43
+ <textarea id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" rows="3"><%%= @<%= singular_table_name %>.<%= attribute.column_name %> %></textarea>
44
44
  <% if with_sentinels? -%>
45
45
  <!-- Input for <%= attribute.column_name %> end -->
46
46
  <% end -%>
@@ -48,7 +48,7 @@
48
48
  <% if with_sentinels? -%>
49
49
  <!-- Input for <%= attribute.column_name %> start -->
50
50
  <% end -%>
51
- <input type="text" id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" class="form-control" value="<%%= @<%= singular_table_name %>.<%= attribute.column_name %> %>">
51
+ <input type="text" id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" value="<%%= @<%= singular_table_name %>.<%= attribute.column_name %> %>">
52
52
  <% if with_sentinels? -%>
53
53
  <!-- Input for <%= attribute.column_name %> end -->
54
54
  <% end -%>
@@ -60,7 +60,7 @@
60
60
  <% end -%>
61
61
 
62
62
  <% end -%>
63
- <button class="btn btn-block btn-outline-secondary">
63
+ <button>
64
64
  Update <%= singular_table_name.humanize.downcase %>
65
65
  </button>
66
66
  </form>
@@ -4,7 +4,7 @@
4
4
  <% end -%>
5
5
  <%% if @<%= singular_table_name %>.errors.any? %>
6
6
  <%% @<%= singular_table_name %>.errors.full_messages.each do |message| %>
7
- <div class="alert">
7
+ <div>
8
8
  <%%= message %>
9
9
  </div>
10
10
  <%% end %>
@@ -30,21 +30,21 @@
30
30
  <!-- Label and input for <%= attribute.column_name %> start -->
31
31
  <% end -%>
32
32
  <% if attribute.field_type == :check_box -%>
33
- <div class="form-check">
33
+ <div>
34
34
  <input type="hidden" value="0" name="<%= attribute.column_name %>">
35
35
  <% if with_sentinels? -%>
36
36
  <!-- Input for <%= attribute.column_name %> start -->
37
37
  <% end -%>
38
- <input id="<%= attribute.column_name %>" class="form-check-input" name="<%= attribute.column_name %>" type="checkbox" value="1" <%%= "checked" if @<%= singular_table_name %>.<%= attribute.column_name %> %>>
38
+ <input id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" type="checkbox" value="1" <%%= "checked" if @<%= singular_table_name %>.<%= attribute.column_name %> %>>
39
39
  <% if with_sentinels? -%>
40
40
  <!-- Input for <%= attribute.column_name %> end -->
41
41
  <% end -%>
42
- <label for="<%= attribute.column_name %>" class="form-check-label">
42
+ <label for="<%= attribute.column_name %>">
43
43
  <%= attribute.column_name.humanize %>
44
44
  </label>
45
45
  </div>
46
46
  <% else -%>
47
- <div class="form-group">
47
+ <div>
48
48
  <label for="<%= attribute.column_name %>">
49
49
  <%= attribute.column_name.humanize %>
50
50
  </label>
@@ -53,7 +53,7 @@
53
53
  <% if with_sentinels? -%>
54
54
  <!-- Input for <%= attribute.column_name %> start -->
55
55
  <% end -%>
56
- <textarea id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" class="form-control" rows="3"><%%= @<%= singular_table_name %>.<%= attribute.column_name %> %></textarea>
56
+ <textarea id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" rows="3"><%%= @<%= singular_table_name %>.<%= attribute.column_name %> %></textarea>
57
57
  <% if with_sentinels? -%>
58
58
  <!-- Input for <%= attribute.column_name %> end -->
59
59
  <% end -%>
@@ -61,7 +61,7 @@
61
61
  <% if with_sentinels? -%>
62
62
  <!-- Input for <%= attribute.column_name %> start -->
63
63
  <% end -%>
64
- <input type="text" id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" class="form-control" value="<%%= @<%= singular_table_name %>.<%= attribute.column_name %> %>">
64
+ <input type="text" id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" value="<%%= @<%= singular_table_name %>.<%= attribute.column_name %> %>">
65
65
  <% if with_sentinels? -%>
66
66
  <!-- Input for <%= attribute.column_name %> end -->
67
67
  <% end -%>
@@ -73,7 +73,7 @@
73
73
  <% end -%>
74
74
 
75
75
  <% end -%>
76
- <button class="btn btn-block btn-outline-secondary">
76
+ <button>
77
77
  Update <%= singular_table_name.humanize.downcase %>
78
78
  </button>
79
79
  </form>
@@ -1,15 +1,59 @@
1
- <div class="row mb-3">
2
- <div class="col-md-12">
1
+ <div>
2
+ <div>
3
3
  <h1>
4
- All <%= plural_table_name.humanize.downcase %>
4
+ List of all <%= plural_table_name.humanize.downcase %>
5
5
  </h1>
6
+ </div>
7
+ </div>
8
+
9
+ <hr>
6
10
 
7
- <a href="/<%= plural_table_name %>/new" class="btn btn-block btn-outline-secondary">
11
+ <div>
12
+ <div>
13
+ <h2>
8
14
  Add a new <%= singular_table_name.humanize.downcase %>
9
- </a>
15
+ </h2>
16
+
17
+ <form action="/insert_<%= singular_table_name %>"<% unless skip_post? -%> method="post"<% end -%>>
18
+ <% attributes.each do |attribute| -%>
19
+ <% if attribute.field_type == :check_box -%>
20
+ <div>
21
+ <input type="checkbox" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" value="1">
22
+
23
+ <label for="<%= attribute.column_name %>_box"><%= attribute.column_name.humanize %></label>
24
+ </div>
25
+
26
+ <% else -%>
27
+ <div>
28
+ <label for="<%= attribute.column_name %>_box">
29
+ <%= attribute.column_name.humanize %>
30
+ </label>
31
+
32
+ <% if attribute.field_type == :text_area -%>
33
+ <textarea id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" rows="3"></textarea>
34
+ <% elsif attribute.field_type.to_s.gsub(/_.*/, "").to_sym == :datetime -%>
35
+ <input type="datetime-local" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>">
36
+ <% elsif attribute.field_type.to_s.gsub(/_.*/, "").to_sym == :date -%>
37
+ <input type="date" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>">
38
+ <% elsif attribute.field_type.to_s.gsub(/_.*/, "").to_sym == :time -%>
39
+ <input type="time" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>">
40
+ <% elsif attribute.field_type.to_s.gsub(/_.*/, "").to_sym == :integer -%>
41
+ <input type="number" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>">
42
+ <% else -%>
43
+ <input type="text" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>">
44
+ <% end -%>
45
+ </div>
46
+
47
+ <% end -%>
48
+ <% end -%>
49
+ <button>
50
+ Create <%= singular_table_name.humanize.downcase %>
51
+ </button>
52
+ </form>
10
53
  </div>
11
54
  </div>
12
55
 
56
+ <hr>
13
57
  <% if with_sentinels? -%>
14
58
  <!-- Ransack Code start -->
15
59
 
@@ -18,13 +62,13 @@
18
62
  <!-- Location Map Code start -->
19
63
 
20
64
  <!-- Location Map Code end -->
21
- <% end -%>
22
65
 
23
66
  <hr>
24
67
 
25
- <div class="row mb-3">
26
- <div class="col-md-12">
27
- <table class="table">
68
+ <% end -%>
69
+ <div>
70
+ <div>
71
+ <table border="1">
28
72
  <tr>
29
73
  <th>
30
74
  ID
@@ -48,50 +92,50 @@
48
92
  </th>
49
93
  </tr>
50
94
 
51
- <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
95
+ <%% @list_of_<%= plural_table_name %>.each do |<%= singular_table_name.indefinitize.gsub(" ", "_") %>| %>
52
96
  <tr>
53
97
  <% if with_sentinels? -%>
54
- <!-- Display <%= singular_table_name %>.id start -->
98
+ <!-- Display <%= singular_table_name.indefinitize.gsub(" ", "_") %>.id start -->
55
99
  <% end -%>
56
100
  <td>
57
- <%%= <%= singular_table_name %>.id %>
101
+ <%%= <%= singular_table_name.indefinitize.gsub(" ", "_") %>.id %>
58
102
  </td>
59
103
  <% if with_sentinels? -%>
60
- <!-- Display <%= singular_table_name %>.id end -->
104
+ <!-- Display <%= singular_table_name.indefinitize.gsub(" ", "_") %>.id end -->
61
105
  <% end -%>
62
106
 
63
107
  <% attributes.each do |attribute| -%>
64
108
  <% if with_sentinels? -%>
65
- <!-- Display <%= singular_table_name %>.<%= attribute.column_name %> start -->
109
+ <!-- Display <%= singular_table_name.indefinitize.gsub(" ", "_") %>.<%= attribute.column_name %> start -->
66
110
  <% end -%>
67
111
  <td>
68
- <%%= <%= singular_table_name %>.<%= attribute.column_name %> %>
112
+ <%%= <%= singular_table_name.indefinitize.gsub(" ", "_") %>.<%= attribute.column_name %> %>
69
113
  </td>
70
114
  <% if with_sentinels? -%>
71
- <!-- Display <%= singular_table_name %>.<%= attribute.column_name %> end -->
115
+ <!-- Display <%= singular_table_name.indefinitize.gsub(" ", "_") %>.<%= attribute.column_name %> end -->
72
116
  <% end -%>
73
117
 
74
118
  <% end -%>
75
119
  <% if with_sentinels? -%>
76
- <!-- Display <%= singular_table_name %>.created_at start -->
120
+ <!-- Display <%= singular_table_name.indefinitize.gsub(" ", "_") %>.created_at start -->
77
121
  <% end -%>
78
122
  <td>
79
- <%%= time_ago_in_words(<%= singular_table_name %>.created_at) %> ago
123
+ <%%= time_ago_in_words(<%= singular_table_name.indefinitize.gsub(" ", "_") %>.created_at) %> ago
80
124
  </td>
81
125
  <% if with_sentinels? -%>
82
- <!-- Display <%= singular_table_name %>.created_at end -->
126
+ <!-- Display <%= singular_table_name.indefinitize.gsub(" ", "_") %>.created_at end -->
83
127
 
84
- <!-- Display <%= singular_table_name %>.updated_at start -->
128
+ <!-- Display <%= singular_table_name.indefinitize.gsub(" ", "_") %>.updated_at start -->
85
129
  <% end -%>
86
130
  <td>
87
- <%%= time_ago_in_words(<%= singular_table_name %>.updated_at) %> ago
131
+ <%%= time_ago_in_words(<%= singular_table_name.indefinitize.gsub(" ", "_") %>.updated_at) %> ago
88
132
  </td>
89
133
  <% if with_sentinels? -%>
90
- <!-- Display <%= singular_table_name %>.updated_at end -->
134
+ <!-- Display <%= singular_table_name.indefinitize.gsub(" ", "_") %>.updated_at end -->
91
135
  <% end -%>
92
136
 
93
137
  <td>
94
- <a href="/<%= plural_table_name %>/<%%= <%= singular_table_name %>.id %>">
138
+ <a href="/<%= plural_table_name %>/<%%= <%= singular_table_name.indefinitize.gsub(" ", "_") %>.id %>">
95
139
  Show details
96
140
  </a>
97
141
  </td>
@@ -100,3 +144,5 @@
100
144
  </table>
101
145
  </div>
102
146
  </div>
147
+
148
+ <hr>
@@ -18,21 +18,21 @@
18
18
  <!-- Label and input for <%= attribute.column_name %> start -->
19
19
  <% end -%>
20
20
  <% if attribute.field_type == :check_box -%>
21
- <div class="form-check">
21
+ <div>
22
22
  <input type="hidden" value="0" name="<%= attribute.column_name %>">
23
23
  <% if with_sentinels? -%>
24
24
  <!-- Input for <%= attribute.column_name %> start -->
25
25
  <% end -%>
26
- <input id="<%= attribute.column_name %>" class="form-check-input" name="<%= attribute.column_name %>" type="checkbox">
26
+ <input id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" type="checkbox">
27
27
  <% if with_sentinels? -%>
28
28
  <!-- Input for <%= attribute.column_name %> end -->
29
29
  <% end -%>
30
- <label for="<%= attribute.column_name %>" class="form-check-label">
30
+ <label for="<%= attribute.column_name %>">
31
31
  <%= attribute.column_name.humanize %>
32
32
  </label>
33
33
  </div>
34
34
  <% else -%>
35
- <div class="form-group">
35
+ <div>
36
36
  <label for="<%= attribute.column_name %>">
37
37
  <%= attribute.column_name.humanize %>
38
38
  </label>
@@ -41,7 +41,7 @@
41
41
  <% if with_sentinels? -%>
42
42
  <!-- Input for <%= attribute.column_name %> start -->
43
43
  <% end -%>
44
- <textarea id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" class="form-control" rows="3"></textarea>
44
+ <textarea id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" rows="3"></textarea>
45
45
  <% if with_sentinels? -%>
46
46
  <!-- Input for <%= attribute.column_name %> end -->
47
47
  <% end -%>
@@ -49,7 +49,7 @@
49
49
  <% if with_sentinels? -%>
50
50
  <!-- Input for <%= attribute.column_name %> start -->
51
51
  <% end -%>
52
- <input type="text" id="<%= attribute.column_name %>" name="<%= attribute.column_name %>" class="form-control">
52
+ <input type="text" id="<%= attribute.column_name %>" name="<%= attribute.column_name %>">
53
53
  <% if with_sentinels? -%>
54
54
  <!-- Input for <%= attribute.column_name %> end -->
55
55
  <% end -%>
@@ -61,7 +61,7 @@
61
61
  <% end -%>
62
62
 
63
63
  <% end -%>
64
- <button class="btn btn-block btn-outline-secondary">
64
+ <button>
65
65
  Create <%= singular_table_name.humanize.downcase %>
66
66
  </button>
67
67
  </form>