scaffold_pico 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -47
  3. data/lib/scaffold/cli.rb +16 -4
  4. data/lib/scaffold/erb_context.rb +11 -0
  5. data/lib/scaffold/generators/base_generator.rb +74 -0
  6. data/lib/scaffold/generators/controller_generator.rb +27 -0
  7. data/lib/scaffold/generators/fabricator_generator.rb +26 -0
  8. data/lib/scaffold/generators/locales_generator.rb +42 -0
  9. data/lib/scaffold/generators/models_generator.rb +53 -0
  10. data/lib/scaffold/generators/routes_generator.rb +48 -0
  11. data/lib/scaffold/generators/views_generator.rb +57 -0
  12. data/lib/scaffold/main.rb +15 -6
  13. data/lib/scaffold/models/resource.rb +66 -0
  14. data/lib/scaffold/rails.rb +54 -0
  15. data/lib/scaffold/services/controller.rb +112 -0
  16. data/lib/scaffold/services/nested_in_resources.rb +42 -0
  17. data/lib/scaffold/services/path.rb +72 -0
  18. data/lib/scaffold/services/resource.rb +73 -0
  19. data/lib/scaffold/services/route.rb +20 -0
  20. data/lib/scaffold/services/view.rb +14 -0
  21. data/lib/scaffold_pico.rb +6 -7
  22. data/lib/templates/pico/controller.rb.erb +34 -26
  23. data/lib/templates/pico/fabricators/fabrication.rb.erb +4 -4
  24. data/lib/templates/pico/locales/bg.scaffold_pico.yml.erb +35 -0
  25. data/lib/templates/pico/locales/en.scaffold_pico.yml.erb +35 -0
  26. data/lib/templates/pico/model.rb.erb +2 -2
  27. data/lib/templates/pico/search.rb.erb +12 -12
  28. data/lib/templates/pico/views/materialize/slim/_form.html.slim.erb +1 -4
  29. data/lib/templates/pico/views/materialize/slim/edit.html.slim.erb +9 -7
  30. data/lib/templates/pico/views/materialize/slim/index.html.slim.erb +15 -15
  31. data/lib/templates/pico/views/materialize/slim/new.html.slim.erb +7 -5
  32. data/lib/templates/pico/views/materialize/slim/show.html.slim.erb +10 -10
  33. data/lib/templates/pico/views/zurb/slim/_form.html.slim.erb +2 -5
  34. data/lib/templates/pico/views/zurb/slim/edit.html.slim.erb +8 -6
  35. data/lib/templates/pico/views/zurb/slim/index.html.slim.erb +14 -14
  36. data/lib/templates/pico/views/zurb/slim/new.html.slim.erb +6 -4
  37. data/lib/templates/pico/views/zurb/slim/show.html.slim.erb +7 -7
  38. metadata +22 -10
  39. data/lib/scaffold/base_generator.rb +0 -60
  40. data/lib/scaffold/controller_generator.rb +0 -24
  41. data/lib/scaffold/fabricator_generator.rb +0 -25
  42. data/lib/scaffold/models_generator.rb +0 -51
  43. data/lib/scaffold/params.rb +0 -174
  44. data/lib/scaffold/routes_generator.rb +0 -29
  45. data/lib/scaffold/views_generator.rb +0 -52
@@ -0,0 +1,20 @@
1
+ module Scaffold
2
+ module Services
3
+ class Route
4
+ def initialize rails
5
+ @rails = rails
6
+ end
7
+
8
+ # resources :company_ownerships
9
+ def resource_name
10
+ @rails.resource.collection_name
11
+ end
12
+
13
+ def nested?
14
+ @rails.nested_in_resources.present?
15
+ end
16
+
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ module Scaffold
2
+ module Services
3
+ class View
4
+ def initialize rails
5
+ @rails = rails
6
+ end
7
+
8
+ def folder_name
9
+ @rails.resource.collection_name
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -1,14 +1,13 @@
1
1
  require 'active_support/inflector'
2
2
  require 'active_support/core_ext/object/blank'
3
3
  require 'ostruct'
4
+
5
+ require 'scaffold/rails'
4
6
  require 'scaffold/main'
5
- require 'scaffold/params'
6
- require 'scaffold/base_generator'
7
- require 'scaffold/controller_generator'
8
- require 'scaffold/models_generator'
9
- require 'scaffold/views_generator'
10
- require 'scaffold/routes_generator'
11
- require 'scaffold/fabricator_generator'
7
+ require 'scaffold/erb_context' # I hate this erb
8
+
9
+ require 'scaffold/models/resource.rb'
10
+
12
11
  require 'scaffold/template_engines/slim'
13
12
  require 'erb'
14
13
  require 'fileutils'
@@ -1,37 +1,45 @@
1
- class <%= @controller_class_name %> < <%= @base_controller %>
1
+ class <%= @rails.controller.class_name %> < <%= @rails.controller.base_controller %>
2
+
3
+ <% @rails.nested_in_resources.each do |resource| -%>
4
+ def <%= resource.name %>
5
+ <%= resource.instance_name %> ||= <%= resource.class_name_with_modules %>.find(params[:<%= resource.param_name %>])
6
+ end
7
+ helper_method :<%= resource.name %>
8
+
9
+ <% end %>
2
10
 
3
11
  def index
4
- <%= "@#{@collection_name}_search = #{@search_modulized_resource_class_name}.new(search_#{@collection_name}_params)" %>
12
+ <%= "@#{@rails.resource.collection_name}_search = #{@rails.resource.search_class_name}.new(search_#{@rails.resource.collection_name}_params)" %>
5
13
  <%=
6
- active_record = ["@#{@collection_name}_search"]
14
+ active_record = ["@#{@rails.resource.collection_name}_search"]
7
15
  active_record << [ "results" ]
8
- active_record << [ "includes(#{@includes.lazy.map(&:strip).map{|v| v.gsub(',', '')}.to_a.join(', ')})" ] if @includes and !@includes.empty?
9
- active_record << [ "joins(#{@joins.join(', ')})" ] if @joins and !@joins.empty?
16
+ active_record << [ "includes(#{@rails.controller.index_includes.lazy.map(&:strip).map{|v| v.gsub(',', '')}.to_a.join(', ')})" ] if @rails.controller.index_includes and !@rails.controller.index_includes.empty?
17
+ active_record << [ "joins(#{@rails.controller.index_joins.join(', ')})" ] if @rails.controller.index_joins and !@rails.controller.index_joins.empty?
10
18
  active_record << [ "page(params[:page])", "per(params[:per])" ]
11
19
  active_record << [ "all" ]
12
- "@#{@collection_name} = #{active_record.join('.')}"
20
+ "@#{@rails.resource.collection_name} = #{active_record.join('.')}"
13
21
  %>
14
22
  end
15
23
 
16
24
  def show
17
- @<%= @resource_name %> = <%= @modulized_resource_class_name %>.find(params[:id])
25
+ @<%= @rails.resource.name %> = <%= @rails.resource.class_name_with_modules %>.find(params[:id])
18
26
  end
19
27
 
20
28
  def new
21
- @<%= @resource_name %> = <%= @modulized_resource_class_name %>.new
29
+ @<%= @rails.resource.name %> = <%= @rails.resource.class_name_with_modules %>.new
22
30
  end
23
31
 
24
32
  def edit
25
- @<%= @resource_name %> = <%= @modulized_resource_class_name %>.find(params[:id])
33
+ @<%= @rails.resource.name %> = <%= @rails.resource.class_name_with_modules %>.find(params[:id])
26
34
  end
27
35
 
28
36
  def create
29
- @<%= @resource_name %> = <%= @modulized_resource_class_name %>.new(<%= @collection_name %>_params)
37
+ @<%= @rails.resource.name %> = <%= @rails.resource.class_name_with_modules %>.new(<%= @rails.resource.collection_name %>_params)
30
38
 
31
39
  respond_to do |format|
32
- if @<%= @resource_name %>.save
33
- <%= "message = t('create', scope: [:scaffold, :notices, :success], model: #{@resource_class_name}.model_name.human.mb_chars.downcase)" %>
34
- format.html { redirect_to <%= @collection_path %>, notice: message }
40
+ if @<%= @rails.resource.name %>.save
41
+ <%= "message = t('create', scope: [:scaffold, :notices, :success], model: #{@rails.resource.class_name}.model_name.human.mb_chars.downcase)" %>
42
+ format.html { redirect_to <%= @rails.path.collection %>, notice: message }
35
43
  else
36
44
  format.html { render :new }
37
45
  end
@@ -39,11 +47,11 @@ class <%= @controller_class_name %> < <%= @base_controller %>
39
47
  end
40
48
 
41
49
  def update
42
- @<%= @resource_name %> = <%= @modulized_resource_class_name %>.find(params[:id])
50
+ @<%= @rails.resource.name %> = <%= @rails.resource.class_name_with_modules %>.find(params[:id])
43
51
  respond_to do |format|
44
- if @<%= @resource_name %>.update(<%= @collection_name %>_params)
45
- <%= "message = t('update', scope: [:scaffold, :notices, :success], model: #{@resource_class_name}.model_name.human.mb_chars.downcase)" %>
46
- format.html { redirect_to <%= @collection_path %>, notice: message }
52
+ if @<%= @rails.resource.name %>.update(<%= @rails.resource.collection_name %>_params)
53
+ <%= "message = t('update', scope: [:scaffold, :notices, :success], model: #{@rails.resource.class_name}.model_name.human.mb_chars.downcase)" %>
54
+ format.html { redirect_to <%= @rails.path.collection %>, notice: message }
47
55
  else
48
56
  format.html { render :edit }
49
57
  end
@@ -51,22 +59,22 @@ class <%= @controller_class_name %> < <%= @base_controller %>
51
59
  end
52
60
 
53
61
  def destroy
54
- @<%= @resource_name %> = <%= @modulized_resource_class_name %>.find(params[:id])
55
- @<%= @resource_name %>.destroy
62
+ @<%= @rails.resource.name %> = <%= @rails.resource.class_name_with_modules %>.find(params[:id])
63
+ @<%= @rails.resource.name %>.destroy
56
64
  respond_to do |format|
57
- <%= "message = t('destroy', scope: [:scaffold, :notices, :success], model: #{@resource_class_name}.model_name.human.mb_chars.downcase)" %>
58
- format.html { redirect_to <%= @collection_path %>, notice: message }
65
+ <%= "message = t('destroy', scope: [:scaffold, :notices, :success], model: #{@rails.resource.class_name}.model_name.human.mb_chars.downcase)" %>
66
+ format.html { redirect_to <%= @rails.path.collection %>, notice: message }
59
67
  end
60
68
  end
61
69
 
62
70
  private
63
- def <%= @collection_name %>_params
64
- params[:<%= @resource_name %>].permit(<%= @fields_permitted.keys.map{|field| ":#{field}"}.join(', ') %>)
71
+ def <%= @rails.resource.collection_name %>_params
72
+ params[:<%= @rails.resource.name %>].permit(<%= @rails.controller.permitted_fields.keys.map{|field| ":#{field}"}.join(', ') %>)
65
73
  end
66
74
 
67
- def search_<%= @collection_name %>_params
68
- return {} if params[:<%= @collection_name %>_search].blank?
69
- params[:<%= @collection_name %>_search].permit(<%= @search_fields_permitted.collect{|field| ":#{field}"}.join(', ') %>)
75
+ def search_<%= @rails.resource.collection_name %>_params
76
+ return {} if params[:<%= @rails.resource.collection_name %>_search].blank?
77
+ params[:<%= @rails.resource.collection_name %>_search].permit(<%= @rails.controller.permitted_search_fields.collect{|field| ":#{field}"}.join(', ') %>)
70
78
  end
71
79
 
72
80
  end
@@ -1,9 +1,9 @@
1
- <% if @modules.empty? -%>
2
- Fabricator(:<%= @resource_name %>) do
1
+ <% if @rails.resource.modules.empty? -%>
2
+ Fabricator(:<%= @rails.resource.name %>) do
3
3
  <% else -%>
4
- Fabricator(:<%= @resource_name %>, class_name: '<%= @modulized_resource_class_name -%>') do
4
+ Fabricator(:<%= @rails.resource.name %>, class_name: '<%= @rails.resource.class_name_with_modules -%>') do
5
5
  <% end -%>
6
- <% @fields.each_pair do |field_name, kind| -%>
6
+ <% @rails.resource.fields.each_pair do |field_name, kind| -%>
7
7
  <% if kind == 'belongs_to' -%>
8
8
  <%= field_name %>
9
9
  <% elsif kind == 'text' -%>
@@ -0,0 +1,35 @@
1
+ bg:
2
+ scaffold:
3
+ confirm: 'Сигурни ли сте?'
4
+ notices:
5
+ success:
6
+ create: Създадохме %{model}
7
+ update: Обновихме %{model}
8
+ destroy: Изтрихме %{model}
9
+ failed:
10
+ create: Неуспешно създаване на %{model}
11
+ update: Неуспешно обновяване на %{model}
12
+ destroy: Неуспешно изтриване на %{model}
13
+ new:
14
+ title: "Нов %{model}"
15
+ show:
16
+ title: "%{model}"
17
+ edit:
18
+ title: "Редакция %{model}"
19
+ index:
20
+ title: "%{model}"
21
+ edit: Редакция
22
+ show: Преглед
23
+ destroy: Изтрии
24
+ actions: Действия
25
+ search:
26
+ header: Търсене
27
+ button: Търси
28
+ reset: Ново
29
+
30
+ actions:
31
+ index: Списък %{model}
32
+ actions: 'Действия'
33
+ new: Нов %{model}
34
+ edit: Редакция %{model}
35
+ create: "Създай %{model}"
@@ -0,0 +1,35 @@
1
+ en:
2
+ scaffold:
3
+ confirm: 'Are you sure?'
4
+ notices:
5
+ success:
6
+ create: Was successfully created %{model}
7
+ update: Was successfully updated %{model}
8
+ destroy: Was successfully destroyed %{model}
9
+ failed:
10
+ create: Fail creating %{model}
11
+ update: Fail updating %{model}
12
+ destroy: Fail destroying %{model}
13
+ new:
14
+ title: "New %{model}"
15
+ show:
16
+ title: "%{model}"
17
+ edit:
18
+ title: "Edit %{model}"
19
+ index:
20
+ title: "%{model}"
21
+ edit: Edit
22
+ show: Show
23
+ destroy: Delete
24
+ actions: Action
25
+ search:
26
+ header: Search
27
+ button: Search
28
+ reset: Reset
29
+
30
+ actions:
31
+ index: List %{model}
32
+ actions: 'Actions'
33
+ new: New %{model}
34
+ edit: Edit %{model}
35
+ create: "Create %{model}"
@@ -1,5 +1,5 @@
1
- class <%= @modulized_resource_class_name %> < ApplicationRecord
2
- <% @fields.select {|k,v| @search_fields.include?(k) }.each_pair do |field_name, field_type| -%>
1
+ class <%= @rails.resource.class_name_with_modules %> < ApplicationRecord
2
+ <% @rails.resource.fields.select {|k,v| @rails.controller.search_fields.include?(k) }.each_pair do |field_name, field_type| -%>
3
3
  <% if field_type == 'belongs_to' -%>
4
4
  belongs_to :<%= field_name %>
5
5
  <% end -%>
@@ -1,8 +1,8 @@
1
- class <%= @search_modulized_resource_class_name %>
1
+ class <%= @rails.resource.search_class_name %>
2
2
  include ActiveModel::Model
3
3
 
4
4
  attr_accessor(
5
- <% @fields.select {|k,v| @search_fields.include?(k) }.each_pair do |field_name, field_type| %>
5
+ <% @rails.resource.fields.select {|k,v| @rails.controller.search_fields.include?(k) }.each_pair do |field_name, field_type| %>
6
6
  <% if field_type == 'belongs_to' -%>
7
7
  :<%= field_name %>_id,
8
8
  <% else %>
@@ -11,37 +11,37 @@ class <%= @search_modulized_resource_class_name %>
11
11
  <% end %>
12
12
  )
13
13
 
14
- <% @fields.select {|k,v| @search_fields.include?(k) }.each_pair do |field_name, field_type| %>
14
+ <% @rails.resource.fields.select {|k,v| @rails.controller.search_fields.include?(k) }.each_pair do |field_name, field_type| %>
15
15
  <%- if field_type == "integer" %>
16
16
  validates :<%= field_name -%>, numericality: { only_integer: true }, allow_blank: true
17
17
  <%- end %>
18
18
  <%- end %>
19
19
 
20
20
  def initialize *args
21
- @relation = <%= @modulized_resource_class_name %>
21
+ @relation = <%= @rails.resource.class_name_with_modules %>
22
22
  super *args
23
23
  end
24
24
 
25
25
  def results
26
- <%= @resource_name %> = @relation
26
+ <%= @rails.resource.name %> = @relation
27
27
 
28
- <%= @resource_name %> = @relation.order("updated_at") if <%= @modulized_resource_class_name %>.respond_to?(:updated_at)
28
+ <%= @rails.resource.name %> = @relation.order("updated_at") if <%= @rails.resource.class_name_with_modules %>.respond_to?(:updated_at)
29
29
 
30
30
  if valid?
31
- <% @fields.select {|k,v| @search_fields.include?(k) }.each_pair do |field_name, field_type| %>
31
+ <% @rails.resource.fields.select {|k,v| @rails.controller.search_fields.include?(k) }.each_pair do |field_name, field_type| %>
32
32
  <% if ['string', 'text'].include?(field_type) -%>
33
- <%= @resource_name %> = <%= @resource_name %>.where("<%= field_name %> LIKE ?", "%#{<%= field_name %>}%") if self.<%= field_name %>.present?
33
+ <%= @rails.resource.name %> = <%= @rails.resource.name %>.where("<%= field_name %> LIKE ?", "%#{<%= field_name %>}%") if self.<%= field_name %>.present?
34
34
  <% elsif field_type == "boolean" -%>
35
- <%= @resource_name %> = <%= @resource_name %>.where(<%= field_name -%>: <%= field_name -%>=='1') if self.<%= field_name %>.present?
35
+ <%= @rails.resource.name %> = <%= @rails.resource.name %>.where(<%= field_name -%>: <%= field_name -%>=='1') if self.<%= field_name %>.present?
36
36
  <% elsif field_type == 'belongs_to' -%>
37
- <%= @resource_name %> = <%= @resource_name %>.where(<%= field_name %>_id: <%= field_name %>_id) if self.<%= field_name %>_id.present?
37
+ <%= @rails.resource.name %> = <%= @rails.resource.name %>.where(<%= field_name %>_id: <%= field_name %>_id) if self.<%= field_name %>_id.present?
38
38
  <% else -%>
39
- <%= @resource_name %> = <%= @resource_name %>.where(<%= field_name %>: <%= field_name %>) if self.<%= field_name %>.present?
39
+ <%= @rails.resource.name %> = <%= @rails.resource.name %>.where(<%= field_name %>: <%= field_name %>) if self.<%= field_name %>.present?
40
40
  <% end -%>
41
41
  <% end -%>
42
42
  end
43
43
 
44
- <%= @resource_name %>
44
+ <%= @rails.resource.name %>
45
45
  end
46
46
 
47
47
  end
@@ -1,6 +1,6 @@
1
1
  = form.error_notification
2
2
  .form-inputs
3
- <% @fields.each_pair do |field_name, kind| -%>
3
+ <% @rails.resource.fields.each_pair do |field_name, kind| -%>
4
4
  <% if kind == 'file' -%>
5
5
  = form.input :<%= field_name -%>, as: :file
6
6
  <% elsif kind == 'belongs_to' -%>
@@ -13,6 +13,3 @@
13
13
  = form.input :<%= field_name %>
14
14
  <% end -%>
15
15
  <% end -%>
16
-
17
- .form-actions
18
- = form.button :button, 'Reset Password', :class => 'btn btn-large waves-effect waves'
@@ -1,20 +1,22 @@
1
- h1 = t('scaffold.edit.title', model: <%= @resource_class_name %>.model_name.human(count: 1).mb_chars.downcase)
1
+ h1 = t('scaffold.edit.title', model: <%= @rails.resource.class_name %>.model_name.human(count: 1).mb_chars.downcase)
2
2
 
3
3
  .section
4
4
  .left
5
- = link_to <%= @collection_path %>, class: 'waves-effect waves-light btn' do
5
+ = link_to <%= @rails.path.collection %>, class: 'waves-effect waves-light btn' do
6
6
  i.material-icons.right view_list
7
- = t('scaffold.show.actions.index', model: <%= @resource_class_name %>.model_name.human(count: 2).mb_chars.downcase)
7
+ = t('scaffold.show.actions.index', model: <%= @rails.resource.class_name %>.model_name.human(count: 2).mb_chars.downcase)
8
8
 
9
9
 
10
10
  .right
11
- = link_to <%= @new_resource_path %>, class: 'btn waves-effect waves-light' do
11
+ = link_to <%= @rails.path.new_resource %>, class: 'btn waves-effect waves-light' do
12
12
  i.material-icons.right add
13
- = t('scaffold.actions.new', model: <%= @resource_class_name %>.model_name.human(count: 1).mb_chars.downcase)
13
+ = t('scaffold.actions.new', model: <%= @rails.resource.class_name %>.model_name.human(count: 1).mb_chars.downcase)
14
14
 
15
15
  .clearfix
16
16
 
17
17
  .card
18
18
  .card-content
19
- = simple_form_for <%= @instance_resource_path %> do |form|
20
- = render 'form', form: form
19
+ = simple_form_for <%= @rails.path.instance_resource %> do |form|
20
+ = render 'form', form: form
21
+ .form-actions
22
+ = form.button :button, t('scaffold.actions.update', model: <%= @rails.resource.class_name_with_modules %>.model_name.human(count: 1)), :class => 'btn btn-large waves-effect waves'
@@ -1,9 +1,9 @@
1
- h1 = t('scaffold.index.title', model: <%= @modulized_resource_class_name %>.model_name.human(count: 2))
1
+ h1 = t('scaffold.index.title', model: <%= @rails.resource.class_name_with_modules %>.model_name.human(count: 2))
2
2
 
3
3
  .fixed-action-btn style="bottom: 45px; right: 24px;"
4
- = link_to <%= @new_resource_path %>, class: 'btn-floating btn-large waves-effect waves-light red' do
4
+ = link_to <%= @rails.path.new_resource %>, class: 'btn-floating btn-large waves-effect waves-light red' do
5
5
  i.material-icons.right add
6
- = t('scaffold.actions.new', model: <%= @modulized_resource_class_name %>.model_name.human(count: 1).mb_chars.downcase)
6
+ = t('scaffold.actions.new', model: <%= @rails.resource.class_name_with_modules %>.model_name.human(count: 1).mb_chars.downcase)
7
7
 
8
8
 
9
9
 
@@ -14,32 +14,32 @@ h1 = t('scaffold.index.title', model: <%= @modulized_resource_class_name %>.mode
14
14
  table.striped.highlight.responsive-table
15
15
  thead
16
16
  tr
17
- <% @fields.select {|k,v| @index_fields.include?(k) }.keys.each do |field_name| %>
18
- th = <%= @modulized_resource_class_name -%>.human_attribute_name(:<%= field_name -%>)
17
+ <% @rails.resource.fields.select {|k,v| @rails.controller.index_fields.include?(k) }.keys.each do |field_name| %>
18
+ th = <%= @rails.resource.class_name_with_modules -%>.human_attribute_name(:<%= field_name -%>)
19
19
  <% end %>
20
20
  th colspan=3 = t('scaffold.index.actions')
21
21
 
22
22
  tbody
23
- - @<%= @collection_name %>.each do |<%= @resource_name %>|
23
+ - @<%= @rails.resource.collection_name %>.each do |<%= @rails.resource.name %>|
24
24
  tr
25
- <% @fields.select {|k,v| @index_fields.include?(k) }.keys.each do |field_name| %>
26
- td = <%= @resource_name %>.<%= field_name -%>
25
+ <% @rails.resource.fields.select {|k,v| @rails.controller.index_fields.include?(k) }.keys.each do |field_name| %>
26
+ td = <%= @rails.resource.name %>.<%= field_name -%>
27
27
  <% end %>
28
- td = link_to t('scaffold.index.show'), <%= @resource_path %>
29
- td = link_to t('scaffold.index.edit'), <%= @edit_resource_path %>
30
- td = link_to t('scaffold.index.destroy'), <%= @resource_path %>, data: {:confirm => t('scaffold.confirm')}, :method => :delete
28
+ td = link_to t('scaffold.index.show'), <%= @rails.path.resource %>
29
+ td = link_to t('scaffold.index.edit'), <%= @rails.path.edit_resource %>
30
+ td = link_to t('scaffold.index.destroy'), <%= @rails.path.resource %>, data: {:confirm => t('scaffold.confirm')}, :method => :delete
31
31
  .card-action
32
- = paginate @<%= @collection_name %>
32
+ = paginate @<%= @rails.resource.collection_name %>
33
33
 
34
34
  .col.s12.m3
35
35
 
36
36
  aside.card.search
37
- = simple_form_for <%= "@#{@collection_name}_search" %>, as: :<%= @collection_name %>_search, url: <%= @collection_path %>, method: :get do |form|
37
+ = simple_form_for <%= "@#{@rails.resource.collection_name}_search" %>, as: :<%= @rails.resource.collection_name %>_search, url: <%= @rails.path.collection %>, method: :get do |form|
38
38
  .card-content
39
39
  h5 = t('scaffold.index.search.header')
40
40
  = form.error_notification
41
41
 
42
- <% @fields.select {|k,v| @search_fields.include?(k) }.each_pair do |field_name, field_type| %>
42
+ <% @rails.resource.fields.select {|k,v| @rails.controller.search_fields.include?(k) }.each_pair do |field_name, field_type| %>
43
43
  <% if field_type == 'belongs_to' -%>
44
44
  = form.input :<%= field_name -%>_id
45
45
  <% elsif ['date', 'datetime'].include?(field_type) -%>
@@ -52,6 +52,6 @@ h1 = t('scaffold.index.title', model: <%= @modulized_resource_class_name %>.mode
52
52
  <% end %>
53
53
 
54
54
  .card-action
55
- = link_to t('scaffold.index.search.reset'), url_for(<%= @collection_path %>), class: 'waves-effect waves-light btn lime lighten-5 black-text'
55
+ = link_to t('scaffold.index.search.reset'), url_for(<%= @rails.path.collection %>), class: 'waves-effect waves-light btn lime lighten-5 black-text'
56
56
  = form.submit t('scaffold.index.search.button'), class: 'right waves-effect waves-light btn'
57
57
  .clearfix
@@ -1,14 +1,16 @@
1
- h1 = t('scaffold.new.title', model: <%= @resource_class_name %>.model_name.human(count: 1).mb_chars.downcase)
1
+ h1 = t('scaffold.new.title', model: <%= @rails.resource.class_name %>.model_name.human(count: 1).mb_chars.downcase)
2
2
 
3
3
  .section
4
4
  .left
5
- = link_to <%= @collection_path %>, class: 'waves-effect waves-light btn' do
5
+ = link_to <%= @rails.path.collection %>, class: 'waves-effect waves-light btn' do
6
6
  i.material-icons.right view_list
7
- = t('scaffold.show.actions.index', model: <%= @resource_class_name %>.model_name.human(count: 2).mb_chars.downcase)
7
+ = t('scaffold.show.actions.index', model: <%= @rails.resource.class_name %>.model_name.human(count: 2).mb_chars.downcase)
8
8
 
9
9
  .clearfix
10
10
 
11
11
  .card
12
12
  .card-content
13
- = simple_form_for <%= @instance_resource_path %> do |form|
14
- = render 'form', form: form
13
+ = simple_form_for <%= @rails.path.instance_resource %> do |form|
14
+ = render 'form', form: form
15
+ .form-actions
16
+ = form.button :button, t('scaffold.actions.create', model: <%= @rails.resource.class_name_with_modules %>.model_name.human(count: 1)), :class => 'btn btn-large waves-effect waves'