authorized_rails_scaffolds 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +13 -26
- data/lib/authorized_rails_scaffolds.rb +11 -2
- data/lib/authorized_rails_scaffolds/controller_macros.rb +22 -0
- data/lib/authorized_rails_scaffolds/factory_macros.rb +65 -0
- data/lib/authorized_rails_scaffolds/helper.rb +38 -115
- data/lib/authorized_rails_scaffolds/rails_erb_scaffold_helper.rb +40 -0
- data/lib/authorized_rails_scaffolds/rails_scaffold_controller_helper.rb +20 -0
- data/lib/authorized_rails_scaffolds/resource_macros.rb +81 -0
- data/lib/authorized_rails_scaffolds/route_example_macros.rb +43 -0
- data/lib/authorized_rails_scaffolds/rspec_scaffold_controller_helper.rb +17 -0
- data/lib/authorized_rails_scaffolds/rspec_scaffold_helper.rb +26 -0
- data/lib/authorized_rails_scaffolds/rspec_scaffold_routing_helper.rb +12 -0
- data/lib/authorized_rails_scaffolds/{rspec_scaffold_generator_view_helper.rb → rspec_scaffold_view_helper.rb} +3 -2
- data/lib/authorized_rails_scaffolds/test_var_macros.rb +40 -0
- data/lib/authorized_rails_scaffolds/version.rb +1 -1
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/_form.html.erb +4 -6
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/controller.rb +50 -34
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/edit.html.erb +2 -4
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/index.html.erb +17 -18
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/new.html.erb +2 -4
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/show.html.erb +15 -17
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/controller_spec.rb +126 -101
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/edit_spec.rb +44 -39
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/index_spec.rb +73 -65
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/model_spec.rb +9 -8
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/new_spec.rb +38 -35
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/routing_spec.rb +21 -10
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/show_spec.rb +37 -20
- data/spec/lib/authorized_rails_scaffolds/rails_erb_scaffold_helper_spec.rb +59 -0
- data/spec/lib/authorized_rails_scaffolds/rails_scaffold_controller_helper_spec.rb +89 -0
- data/spec/lib/authorized_rails_scaffolds/rspec_scaffold_controller_helper_spec.rb +155 -0
- data/spec/lib/authorized_rails_scaffolds/{rspec_scaffold_generator_helper_spec.rb → rspec_scaffold_routing_helper_spec.rb} +57 -50
- data/spec/lib/authorized_rails_scaffolds/rspec_scaffold_view_helper_spec.rb +86 -0
- data/spec/spec_helper.rb +5 -2
- data/spec/support/rails_erb_scaffold_helper_macros.rb +15 -0
- data/spec/support/rails_scaffold_controller_helper_macros.rb +15 -0
- data/spec/support/{rspec_scaffold_generator_helper_macros.rb → rspec_scaffold_controller_helper_macros.rb} +2 -2
- data/spec/support/rspec_scaffold_routing_helper_macros.rb +15 -0
- data/spec/support/rspec_scaffold_view_helper_macros.rb +15 -0
- metadata +66 -28
- data/lib/authorized_rails_scaffolds/rspec_scaffold_generator_helper.rb +0 -82
@@ -0,0 +1,43 @@
|
|
1
|
+
module RouteExampleMacros
|
2
|
+
|
3
|
+
# Example index route: i.e. /awesome/users/2/foo_bars
|
4
|
+
def example_controller_path
|
5
|
+
unless @example_controller_path
|
6
|
+
example_controller_path_parts = []
|
7
|
+
|
8
|
+
parent_model_tables.each do |parent_model|
|
9
|
+
# users, 2
|
10
|
+
parent_value = example_parent_values["#{parent_model}_id"]
|
11
|
+
example_controller_path_parts << parent_model.pluralize
|
12
|
+
example_controller_path_parts << parent_value
|
13
|
+
end
|
14
|
+
|
15
|
+
# Example index route: i.e. /awesome/users/2/foo_bars
|
16
|
+
@example_controller_path = [parent_module_groups + example_controller_path_parts + [resource_table_name.pluralize]].join("/")
|
17
|
+
end
|
18
|
+
"/#{@example_controller_path}"
|
19
|
+
end
|
20
|
+
|
21
|
+
# Extra params for an example controller path: i.e. ', :user_id => 2'
|
22
|
+
def example_controller_path_extra_params
|
23
|
+
@example_controller_path_extra_params ||= example_parent_values.any? ? ', ' + example_parent_values.map{ |parent_model_id, parent_value| ":#{parent_model_id} => \"#{parent_value}\"" }.join(', ') : ''
|
24
|
+
end
|
25
|
+
|
26
|
+
def example_route_extra_params
|
27
|
+
@example_route_extra_params ||= parent_model_tables.collect{ |parent_table| ":#{parent_table}_id => #{references_test_property(parent_table)}.to_param" }
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
# Creates example values for parent id params (i.e. :user_id => 2)
|
33
|
+
def example_parent_values
|
34
|
+
unless @example_parent_values
|
35
|
+
@example_parent_values = {}
|
36
|
+
parent_model_tables.each_with_index do |parent_model, index|
|
37
|
+
@example_parent_values["#{parent_model}_id"] = index + 2
|
38
|
+
end
|
39
|
+
end
|
40
|
+
@example_parent_values
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class AuthorizedRailsScaffolds::RSpecScaffoldControllerHelper < AuthorizedRailsScaffolds::RSpecScaffoldHelper
|
2
|
+
include ControllerMacros
|
3
|
+
include FactoryMacros
|
4
|
+
include RouteExampleMacros
|
5
|
+
|
6
|
+
def initialize(options = {})
|
7
|
+
super options
|
8
|
+
|
9
|
+
# Modularized class name generated by spec generator
|
10
|
+
@controller_class_name = options[:controller_class_name]
|
11
|
+
end
|
12
|
+
|
13
|
+
def build_example_request_params(*extra_params)
|
14
|
+
[example_route_extra_params + extra_params].join(", ")
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class AuthorizedRailsScaffolds::RSpecScaffoldHelper < AuthorizedRailsScaffolds::Helper
|
2
|
+
include TestVarMacros
|
3
|
+
|
4
|
+
def initialize(options = {})
|
5
|
+
super options
|
6
|
+
|
7
|
+
@modular_class_name = options[:class_name] || options[:local_class_name]
|
8
|
+
@attributes = options[:attributes]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Class name with parent modules included (i.e. Example::FooBar)
|
12
|
+
# Name of class assumed by default generators, used as a base for determining modules and class
|
13
|
+
def modular_class_name
|
14
|
+
@modular_class_name
|
15
|
+
end
|
16
|
+
|
17
|
+
def parent_variables
|
18
|
+
@parent_variables ||= parent_model_tables.collect{ |parent_table| references_test_property(parent_table) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def references_show_route(attribute_name, variable = nil)
|
22
|
+
variable ||= "#{resource_test_property}.#{attribute_name}"
|
23
|
+
super attribute_name, variable
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class AuthorizedRailsScaffolds::RSpecScaffoldRoutingHelper < AuthorizedRailsScaffolds::RSpecScaffoldHelper
|
2
|
+
include ControllerMacros
|
3
|
+
include RouteExampleMacros
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
super options
|
7
|
+
|
8
|
+
# Modularized class name generated by spec generator
|
9
|
+
@controller_class_name = options[:controller_class_name]
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
class AuthorizedRailsScaffolds::
|
1
|
+
class AuthorizedRailsScaffolds::RSpecScaffoldViewHelper < AuthorizedRailsScaffolds::RSpecScaffoldHelper
|
2
|
+
include FactoryMacros
|
2
3
|
|
3
4
|
def initialize(options = {})
|
4
5
|
super options
|
@@ -13,7 +14,7 @@ class AuthorizedRailsScaffolds::RSpecScaffoldGeneratorViewHelper < AuthorizedRai
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def standard_attributes
|
16
|
-
@standard_attributes ||= @attributes.reject{|attribute| [:time, :date, :datetime].include? attribute.type }
|
17
|
+
@standard_attributes ||= @attributes.reject{|attribute| [:time, :date, :datetime, :references].include? attribute.type }
|
17
18
|
end
|
18
19
|
|
19
20
|
def datetime_attributes
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module TestVarMacros
|
2
|
+
|
3
|
+
# Variable to hold stubs of parent models
|
4
|
+
def references_test_var(references_table)
|
5
|
+
"@#{references_test_property(references_table)}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def references_test_sym(references_table)
|
9
|
+
":#{references_test_property(references_table)}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def references_test_property(references_table, var_number = nil)
|
13
|
+
if parent_model_tables.include? references_table
|
14
|
+
parent_property = "parent_#{references_table}"
|
15
|
+
else
|
16
|
+
parent_property = "stub_#{references_table}"
|
17
|
+
end
|
18
|
+
parent_property = "#{parent_property}_#{var_number}" unless var_number.nil?
|
19
|
+
parent_property
|
20
|
+
end
|
21
|
+
|
22
|
+
# Variable name stub resource is assigned to (i.e. @foo_bar)
|
23
|
+
def resource_test_var(var_number = nil)
|
24
|
+
"@#{resource_test_property(var_number)}"
|
25
|
+
end
|
26
|
+
|
27
|
+
# Symbol used to assign test resources (i.e. :foo_bar)
|
28
|
+
def resource_test_sym(var_number = nil)
|
29
|
+
":#{resource_test_property(var_number)}"
|
30
|
+
end
|
31
|
+
|
32
|
+
# Generator for properties used for testing
|
33
|
+
def resource_test_property(var_number = nil)
|
34
|
+
resource_property = "test_#{var_name}"
|
35
|
+
resource_property = "#{resource_property}_#{var_number}" unless var_number.nil?
|
36
|
+
resource_property
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
end
|
data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/_form.html.erb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
<%-
|
2
2
|
|
3
|
-
t_helper = AuthorizedRailsScaffolds::
|
3
|
+
t_helper = AuthorizedRailsScaffolds::RailsErbScaffoldHelper.new(
|
4
4
|
:class_name => class_name,
|
5
5
|
:singular_table_name => singular_table_name,
|
6
6
|
:file_name => file_name
|
7
7
|
)
|
8
8
|
|
9
|
-
|
10
|
-
var_name = t_helper.var_name # Non-namespaced variable name
|
11
|
-
plural_var_name = t_helper.plural_var_name # Pluralized non-namespaced variable name
|
9
|
+
resource_var = t_helper.resource_var
|
12
10
|
|
13
11
|
-%>
|
14
|
-
<%%= simple_form_for(<%= t_helper.
|
12
|
+
<%%= simple_form_for(<%= t_helper.scoped_values_for_form %>, :html => { class: 'form-horizontal' }) do |f| %>
|
15
13
|
<%%= f.error_notification %>
|
16
14
|
|
17
15
|
<div class="form-inputs">
|
@@ -23,7 +21,7 @@ plural_var_name = t_helper.plural_var_name # Pluralized non-namespaced variable
|
|
23
21
|
<div class="form-actions">
|
24
22
|
<%%= f.button :submit, :class => 'btn-primary' %>
|
25
23
|
<%%= link_to t('.cancel', :default => t("helpers.links.cancel")),
|
26
|
-
|
24
|
+
<%= resource_var %>.persisted? ? <%= t_helper.controller_show_route resource_var %> : <%= t_helper.controller_index_path %>,
|
27
25
|
:class => 'btn'
|
28
26
|
%>
|
29
27
|
</div>
|
data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/controller.rb
CHANGED
@@ -4,74 +4,90 @@ require_dependency "<%= namespaced_file_path %>/application_controller"
|
|
4
4
|
<% end -%>
|
5
5
|
<%-
|
6
6
|
|
7
|
-
|
7
|
+
#
|
8
|
+
# Available properties:
|
9
|
+
#
|
10
|
+
# class_name
|
11
|
+
# controller_class_name
|
12
|
+
# singular_table_name
|
13
|
+
# file_name
|
14
|
+
# orm_instance
|
15
|
+
# route_url
|
16
|
+
#
|
17
|
+
|
18
|
+
t_helper = AuthorizedRailsScaffolds::RailsScaffoldControllerHelper.new(
|
8
19
|
:class_name => class_name,
|
20
|
+
:controller_class_name => controller_class_name,
|
9
21
|
:singular_table_name => singular_table_name,
|
10
22
|
:file_name => file_name
|
11
23
|
)
|
12
24
|
|
13
|
-
|
14
|
-
|
15
|
-
|
25
|
+
resource_class = t_helper.resource_class # Non-Namespaced class name
|
26
|
+
resource_symbol = t_helper.resource_symbol
|
27
|
+
resource_table_name = t_helper.resource_table_name
|
28
|
+
resource_var = t_helper.resource_var
|
29
|
+
resources_var = t_helper.resources_var # Pluralized non-namespaced variable name
|
30
|
+
|
31
|
+
example_controller_path = t_helper.example_controller_path
|
16
32
|
|
17
33
|
# Override default orm instance
|
18
|
-
orm_instance = Rails::Generators::ActiveModel.new
|
34
|
+
orm_instance = Rails::Generators::ActiveModel.new resource_table_name
|
19
35
|
|
20
36
|
-%>
|
21
37
|
<% module_namespacing do -%>
|
22
|
-
class <%= controller_class_name %>
|
38
|
+
class <%= t_helper.controller_class_name %> < <%= t_helper.application_controller_class %>
|
23
39
|
<%- AuthorizedRailsScaffolds.config.parent_models.each_with_index do |model, model_index| -%>
|
24
40
|
load_and_authorize_resource :<%= model.underscore %><% if model_index > 0 %>, :through => :<%= AuthorizedRailsScaffolds.config.parent_models[model_index - 1].underscore %><% end %>
|
25
41
|
<%- end -%>
|
26
|
-
load_and_authorize_resource :<%=
|
42
|
+
load_and_authorize_resource :<%= t_helper.resource_table_name %><% if t_helper.parent_models.any? %>, :through => :<%= t_helper.parent_models.last.underscore %><% end %>
|
27
43
|
|
28
|
-
# GET <%=
|
29
|
-
# GET <%=
|
44
|
+
# GET <%= example_controller_path %>
|
45
|
+
# GET <%= example_controller_path %>.json
|
30
46
|
def index
|
31
|
-
#
|
47
|
+
# <%= resources_var %> = <%= orm_class.all(resource_class) %>
|
32
48
|
|
33
49
|
respond_to do |format|
|
34
50
|
format.html # index.html.erb
|
35
|
-
format.json { render <%= key_value :json,
|
51
|
+
format.json { render <%= key_value :json, resources_var %> }
|
36
52
|
end
|
37
53
|
end
|
38
54
|
|
39
|
-
# GET <%=
|
40
|
-
# GET <%=
|
55
|
+
# GET <%= example_controller_path %>/1
|
56
|
+
# GET <%= example_controller_path %>/1.json
|
41
57
|
def show
|
42
|
-
#
|
58
|
+
# <%= resource_var %> = <%= orm_class.find(resource_class, "params[:id]") %>
|
43
59
|
|
44
60
|
respond_to do |format|
|
45
61
|
format.html # show.html.erb
|
46
|
-
format.json { render <%= key_value :json,
|
62
|
+
format.json { render <%= key_value :json, resource_var %> }
|
47
63
|
end
|
48
64
|
end
|
49
65
|
|
50
|
-
# GET <%=
|
51
|
-
# GET <%=
|
66
|
+
# GET <%= example_controller_path %>/new
|
67
|
+
# GET <%= example_controller_path %>/new.json
|
52
68
|
def new
|
53
|
-
#
|
69
|
+
# <%= resource_var %> = <%= orm_class.build(resource_class) %>
|
54
70
|
|
55
71
|
respond_to do |format|
|
56
72
|
format.html # new.html.erb
|
57
|
-
format.json { render <%= key_value :json,
|
73
|
+
format.json { render <%= key_value :json, resource_table_name %> }
|
58
74
|
end
|
59
75
|
end
|
60
76
|
|
61
|
-
# GET <%=
|
77
|
+
# GET <%= example_controller_path %>/1/edit
|
62
78
|
def edit
|
63
|
-
#
|
79
|
+
# <%= resource_var %> = <%= orm_class.find(resource_class, "params[:id]") %>
|
64
80
|
end
|
65
81
|
|
66
|
-
# POST <%=
|
67
|
-
# POST <%=
|
82
|
+
# POST <%= example_controller_path %>
|
83
|
+
# POST <%= example_controller_path %>.json
|
68
84
|
def create
|
69
|
-
#
|
85
|
+
# <%= resource_var %> = <%= orm_class.build(resource_class, "params[#{resource_symbol}]") %>
|
70
86
|
|
71
87
|
respond_to do |format|
|
72
88
|
if @<%= orm_instance.save %>
|
73
|
-
format.html { redirect_to <%= t_helper.controller_show_route(
|
74
|
-
format.json { render <%= key_value :json,
|
89
|
+
format.html { redirect_to <%= t_helper.controller_show_route(resource_var) %>, <%= key_value :notice, "'#{human_name} was successfully created.'" %> }
|
90
|
+
format.json { render <%= key_value :json, resource_var %>, <%= key_value :status, ':created' %>, <%= key_value :location, t_helper.controller_show_route(resource_var) %> }
|
75
91
|
else
|
76
92
|
format.html { render <%= key_value :action, '"new"' %> }
|
77
93
|
format.json { render <%= key_value :json, "@#{orm_instance.errors}" %>, <%= key_value :status, ':unprocessable_entity' %> }
|
@@ -79,14 +95,14 @@ class <%= controller_class_name %>Controller < <%= t_helper.ns_controller_prefix
|
|
79
95
|
end
|
80
96
|
end
|
81
97
|
|
82
|
-
# PUT <%=
|
83
|
-
# PUT <%=
|
98
|
+
# PUT <%= example_controller_path %>/1
|
99
|
+
# PUT <%= example_controller_path %>/1.json
|
84
100
|
def update
|
85
|
-
#
|
101
|
+
# <%= resource_var %> = <%= orm_class.find(resource_class, "params[:id]") %>
|
86
102
|
|
87
103
|
respond_to do |format|
|
88
|
-
if @<%= orm_instance.update_attributes("params[
|
89
|
-
format.html { redirect_to <%= t_helper.controller_show_route
|
104
|
+
if @<%= orm_instance.update_attributes("params[#{resource_symbol}]") %>
|
105
|
+
format.html { redirect_to <%= t_helper.controller_show_route resource_var %>, <%= key_value :notice, "'#{human_name} was successfully updated.'" %> }
|
90
106
|
format.json { head :no_content }
|
91
107
|
else
|
92
108
|
format.html { render <%= key_value :action, '"edit"' %> }
|
@@ -95,10 +111,10 @@ class <%= controller_class_name %>Controller < <%= t_helper.ns_controller_prefix
|
|
95
111
|
end
|
96
112
|
end
|
97
113
|
|
98
|
-
# DELETE <%=
|
99
|
-
# DELETE <%=
|
114
|
+
# DELETE <%= example_controller_path %>/1
|
115
|
+
# DELETE <%= example_controller_path %>/1.json
|
100
116
|
def destroy
|
101
|
-
#
|
117
|
+
# <%= resource_var %> = <%= orm_class.find(resource_class, "params[:id]") %>
|
102
118
|
@<%= orm_instance.destroy %>
|
103
119
|
|
104
120
|
respond_to do |format|
|
data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/edit.html.erb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
<%-
|
2
2
|
|
3
|
-
t_helper = AuthorizedRailsScaffolds::
|
3
|
+
t_helper = AuthorizedRailsScaffolds::RailsErbScaffoldHelper.new(
|
4
4
|
:class_name => class_name,
|
5
5
|
:singular_table_name => singular_table_name,
|
6
6
|
:file_name => file_name
|
7
7
|
)
|
8
8
|
|
9
|
-
local_class_name = t_helper.local_class_name # Non-Namespaced class name
|
10
|
-
|
11
9
|
-%>
|
12
|
-
<%%- model_class = <%=
|
10
|
+
<%%- model_class = <%= t_helper.resource_class %> -%>
|
13
11
|
<div class="page-header">
|
14
12
|
<h1><%%=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human %></h1>
|
15
13
|
</div>
|
data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/index.html.erb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
<%-
|
2
2
|
|
3
|
-
t_helper = AuthorizedRailsScaffolds::
|
3
|
+
t_helper = AuthorizedRailsScaffolds::RailsErbScaffoldHelper.new(
|
4
4
|
:class_name => class_name,
|
5
5
|
:singular_table_name => singular_table_name,
|
6
6
|
:file_name => file_name
|
7
7
|
)
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
plural_var_name = t_helper.plural_var_name # Pluralized non-namespaced variable name
|
9
|
+
resource_class = t_helper.resource_class
|
10
|
+
resource_table_name = t_helper.resource_table_name # Non-namespaced variable name
|
12
11
|
|
13
12
|
-%>
|
14
|
-
<%%- model_class = <%=
|
13
|
+
<%%- model_class = <%= resource_class %> -%>
|
15
14
|
<div class="page-header">
|
16
15
|
<h1><%%=t '.title', :default => model_class.model_name.human.pluralize %></h1>
|
17
16
|
</div>
|
@@ -33,36 +32,36 @@ plural_var_name = t_helper.plural_var_name # Pluralized non-namespaced variable
|
|
33
32
|
</tr>
|
34
33
|
</thead>
|
35
34
|
<tbody>
|
36
|
-
<%%
|
37
|
-
<tr class="<%=
|
38
|
-
<td class="id-column"><%%= <%=
|
35
|
+
<%% <%= t_helper.resources_var %>.each do |<%= resource_table_name %>| %>
|
36
|
+
<tr class="<%= resource_table_name %>_<%%= <%= resource_table_name %>.id %>">
|
37
|
+
<td class="id-column"><%%= <%= resource_table_name %>.id %></td>
|
39
38
|
<%- if attributes.any? -%>
|
40
|
-
<td class="title-column"><%%= link_to <%=
|
39
|
+
<td class="title-column"><%%= link_to <%= resource_table_name %>.<%= attributes[0].name %>, <%= t_helper.controller_show_route(resource_table_name) %> %></td>
|
41
40
|
<%- attributes[1..-1].each do |attribute| -%>
|
42
41
|
<%- if attribute.type == :references -%>
|
43
42
|
<%% unless @<%= attribute.name %> %>
|
44
|
-
<td><%%= <%=
|
43
|
+
<td><%%= <%= resource_table_name %>.<%= attribute.name %> %></td>
|
45
44
|
<%% end %>
|
46
45
|
<%- elsif [:datetime, :timestamp, :time, :date].include? attribute.type -%>
|
47
|
-
<td><%% unless <%=
|
46
|
+
<td><%% unless <%= resource_table_name %>.<%= attribute.name %>.nil? %><%%=l <%= resource_table_name %>.<%= attribute.name %><% if attribute.type == :datetime %>, :format => :long<% end %><% if attribute.type == :time %>, :format => :short<% end %> %><%% end %></td>
|
48
47
|
<%- else -%>
|
49
|
-
<td><%%= <%=
|
48
|
+
<td><%%= <%= resource_table_name %>.<%= attribute.name %> %></td>
|
50
49
|
<%- end -%>
|
51
50
|
<%- end -%>
|
52
51
|
<%- end -%>
|
53
|
-
<td><%%=l <%=
|
52
|
+
<td><%%=l <%= resource_table_name %>.created_at, :format => :long %></td>
|
54
53
|
<td class="table-actions">
|
55
54
|
<%%= link_to t('.edit', :default => t("helpers.links.edit")),
|
56
|
-
edit_<%= t_helper.controller_show_route
|
55
|
+
edit_<%= t_helper.controller_show_route resource_table_name %>,
|
57
56
|
:class => 'btn btn-mini',
|
58
|
-
:disabled => !can?(:update, <%=
|
57
|
+
:disabled => !can?(:update, <%= resource_table_name %>)
|
59
58
|
%>
|
60
59
|
<%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
|
61
|
-
<%= t_helper.controller_show_route
|
60
|
+
<%= t_helper.controller_show_route resource_table_name %>,
|
62
61
|
:method => :delete,
|
63
62
|
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
|
64
63
|
:class => 'btn btn-mini btn-danger',
|
65
|
-
:disabled => !can?(:destroy, <%=
|
64
|
+
:disabled => !can?(:destroy, <%= resource_table_name %>)
|
66
65
|
%>
|
67
66
|
</td>
|
68
67
|
</tr>
|
@@ -70,7 +69,7 @@ plural_var_name = t_helper.plural_var_name # Pluralized non-namespaced variable
|
|
70
69
|
</tbody>
|
71
70
|
</table>
|
72
71
|
|
73
|
-
<%% if can?(:create, <%=
|
72
|
+
<%% if can?(:create, <%= resource_class %>) %>
|
74
73
|
<%%= link_to t('.new', :default => t("helpers.links.new")),
|
75
74
|
new_<%= t_helper.controller_show_route %>,
|
76
75
|
:class => 'btn btn-primary' %>
|