authorized_rails_scaffolds 0.0.10 → 0.0.11

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 (42) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +13 -26
  3. data/lib/authorized_rails_scaffolds.rb +11 -2
  4. data/lib/authorized_rails_scaffolds/controller_macros.rb +22 -0
  5. data/lib/authorized_rails_scaffolds/factory_macros.rb +65 -0
  6. data/lib/authorized_rails_scaffolds/helper.rb +38 -115
  7. data/lib/authorized_rails_scaffolds/rails_erb_scaffold_helper.rb +40 -0
  8. data/lib/authorized_rails_scaffolds/rails_scaffold_controller_helper.rb +20 -0
  9. data/lib/authorized_rails_scaffolds/resource_macros.rb +81 -0
  10. data/lib/authorized_rails_scaffolds/route_example_macros.rb +43 -0
  11. data/lib/authorized_rails_scaffolds/rspec_scaffold_controller_helper.rb +17 -0
  12. data/lib/authorized_rails_scaffolds/rspec_scaffold_helper.rb +26 -0
  13. data/lib/authorized_rails_scaffolds/rspec_scaffold_routing_helper.rb +12 -0
  14. data/lib/authorized_rails_scaffolds/{rspec_scaffold_generator_view_helper.rb → rspec_scaffold_view_helper.rb} +3 -2
  15. data/lib/authorized_rails_scaffolds/test_var_macros.rb +40 -0
  16. data/lib/authorized_rails_scaffolds/version.rb +1 -1
  17. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/_form.html.erb +4 -6
  18. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/controller.rb +50 -34
  19. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/edit.html.erb +2 -4
  20. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/index.html.erb +17 -18
  21. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/new.html.erb +2 -4
  22. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/show.html.erb +15 -17
  23. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/controller_spec.rb +126 -101
  24. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/edit_spec.rb +44 -39
  25. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/index_spec.rb +73 -65
  26. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/model_spec.rb +9 -8
  27. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/new_spec.rb +38 -35
  28. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/routing_spec.rb +21 -10
  29. data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/show_spec.rb +37 -20
  30. data/spec/lib/authorized_rails_scaffolds/rails_erb_scaffold_helper_spec.rb +59 -0
  31. data/spec/lib/authorized_rails_scaffolds/rails_scaffold_controller_helper_spec.rb +89 -0
  32. data/spec/lib/authorized_rails_scaffolds/rspec_scaffold_controller_helper_spec.rb +155 -0
  33. data/spec/lib/authorized_rails_scaffolds/{rspec_scaffold_generator_helper_spec.rb → rspec_scaffold_routing_helper_spec.rb} +57 -50
  34. data/spec/lib/authorized_rails_scaffolds/rspec_scaffold_view_helper_spec.rb +86 -0
  35. data/spec/spec_helper.rb +5 -2
  36. data/spec/support/rails_erb_scaffold_helper_macros.rb +15 -0
  37. data/spec/support/rails_scaffold_controller_helper_macros.rb +15 -0
  38. data/spec/support/{rspec_scaffold_generator_helper_macros.rb → rspec_scaffold_controller_helper_macros.rb} +2 -2
  39. data/spec/support/rspec_scaffold_routing_helper_macros.rb +15 -0
  40. data/spec/support/rspec_scaffold_view_helper_macros.rb +15 -0
  41. metadata +66 -28
  42. 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::RSpecScaffoldGeneratorViewHelper < AuthorizedRailsScaffolds::RSpecScaffoldGeneratorHelper
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
@@ -1,3 +1,3 @@
1
1
  module AuthorizedRailsScaffolds
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -1,17 +1,15 @@
1
1
  <%-
2
2
 
3
- t_helper = AuthorizedRailsScaffolds::Helper.new(
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
- 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.form_object_array %>, :html => { class: 'form-horizontal' }) do |f| %>
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
- @<%= var_name %>.persisted? ? <%= t_helper.controller_show_route "@#{var_name}" %> : <%= t_helper.controller_index_path %>,
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>
@@ -4,74 +4,90 @@ require_dependency "<%= namespaced_file_path %>/application_controller"
4
4
  <% end -%>
5
5
  <%-
6
6
 
7
- t_helper = AuthorizedRailsScaffolds::Helper.new(
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
- local_class_name = t_helper.local_class_name # Non-Namespaced class name
14
- var_name = t_helper.var_name # Non-namespaced variable name
15
- plural_var_name = t_helper.plural_var_name # Pluralized non-namespaced variable name
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 var_name
34
+ orm_instance = Rails::Generators::ActiveModel.new resource_table_name
19
35
 
20
36
  -%>
21
37
  <% module_namespacing do -%>
22
- class <%= controller_class_name %>Controller < <%= t_helper.ns_controller_prefix %>ApplicationController
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 :<%= var_name%><% if AuthorizedRailsScaffolds.config.parent_models.any? %>, :through => :<%= AuthorizedRailsScaffolds.config.parent_models.last.underscore %><% end %>
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 <%= route_url %>
29
- # GET <%= route_url %>.json
44
+ # GET <%= example_controller_path %>
45
+ # GET <%= example_controller_path %>.json
30
46
  def index
31
- # @<%= plural_var_name %> = <%= orm_class.all(local_class_name) %>
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, "@#{plural_var_name}" %> }
51
+ format.json { render <%= key_value :json, resources_var %> }
36
52
  end
37
53
  end
38
54
 
39
- # GET <%= route_url %>/1
40
- # GET <%= route_url %>/1.json
55
+ # GET <%= example_controller_path %>/1
56
+ # GET <%= example_controller_path %>/1.json
41
57
  def show
42
- # @<%= var_name %> = <%= orm_class.find(local_class_name, "params[:id]") %>
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, "@#{var_name}" %> }
62
+ format.json { render <%= key_value :json, resource_var %> }
47
63
  end
48
64
  end
49
65
 
50
- # GET <%= route_url %>/new
51
- # GET <%= route_url %>/new.json
66
+ # GET <%= example_controller_path %>/new
67
+ # GET <%= example_controller_path %>/new.json
52
68
  def new
53
- # @<%= var_name %> = <%= orm_class.build(local_class_name) %>
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, "@#{var_name}" %> }
73
+ format.json { render <%= key_value :json, resource_table_name %> }
58
74
  end
59
75
  end
60
76
 
61
- # GET <%= route_url %>/1/edit
77
+ # GET <%= example_controller_path %>/1/edit
62
78
  def edit
63
- # @<%= var_name %> = <%= orm_class.find(local_class_name, "params[:id]") %>
79
+ # <%= resource_var %> = <%= orm_class.find(resource_class, "params[:id]") %>
64
80
  end
65
81
 
66
- # POST <%= route_url %>
67
- # POST <%= route_url %>.json
82
+ # POST <%= example_controller_path %>
83
+ # POST <%= example_controller_path %>.json
68
84
  def create
69
- # @<%= var_name %> = <%= orm_class.build(local_class_name, "params[:#{var_name}]") %>
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("@#{var_name}") %>, <%= key_value :notice, "'#{human_name} was successfully created.'" %> }
74
- format.json { render <%= key_value :json, "@#{var_name}" %>, <%= key_value :status, ':created' %>, <%= key_value :location, t_helper.controller_show_route("@#{var_name}") %> }
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 <%= route_url %>/1
83
- # PUT <%= route_url %>/1.json
98
+ # PUT <%= example_controller_path %>/1
99
+ # PUT <%= example_controller_path %>/1.json
84
100
  def update
85
- # @<%= var_name %> = <%= orm_class.find(local_class_name, "params[:id]") %>
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[:#{var_name}]") %>
89
- format.html { redirect_to <%= t_helper.controller_show_route "@#{var_name}" %>, <%= key_value :notice, "'#{human_name} was successfully updated.'" %> }
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 <%= route_url %>/1
99
- # DELETE <%= route_url %>/1.json
114
+ # DELETE <%= example_controller_path %>/1
115
+ # DELETE <%= example_controller_path %>/1.json
100
116
  def destroy
101
- # @<%= var_name %> = <%= orm_class.find(local_class_name, "params[:id]") %>
117
+ # <%= resource_var %> = <%= orm_class.find(resource_class, "params[:id]") %>
102
118
  @<%= orm_instance.destroy %>
103
119
 
104
120
  respond_to do |format|
@@ -1,15 +1,13 @@
1
1
  <%-
2
2
 
3
- t_helper = AuthorizedRailsScaffolds::Helper.new(
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 = <%= local_class_name %> -%>
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>
@@ -1,17 +1,16 @@
1
1
  <%-
2
2
 
3
- t_helper = AuthorizedRailsScaffolds::Helper.new(
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
- 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_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 = <%= local_class_name %> -%>
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
- <%% @<%= plural_var_name %>.each do |<%= var_name %>| %>
37
- <tr class="<%= var_name %>_<%%= <%= var_name %>.id %>">
38
- <td class="id-column"><%%= <%= var_name %>.id %></td>
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 <%= var_name %>.<%= attributes[0].name %>, <%= t_helper.controller_show_route(var_name) %> %></td>
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><%%= <%= var_name %>.<%= attribute.name %> %></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 <%= var_name %>.<%= attribute.name %>.nil? %><%%=l <%= var_name %>.<%= attribute.name %><% if attribute.type == :datetime %>, :format => :long<% end %><% if attribute.type == :time %>, :format => :short<% end %> %><%% end %></td>
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><%%= <%= var_name %>.<%= attribute.name %> %></td>
48
+ <td><%%= <%= resource_table_name %>.<%= attribute.name %> %></td>
50
49
  <%- end -%>
51
50
  <%- end -%>
52
51
  <%- end -%>
53
- <td><%%=l <%= var_name %>.created_at, :format => :long %></td>
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 var_name %>,
55
+ edit_<%= t_helper.controller_show_route resource_table_name %>,
57
56
  :class => 'btn btn-mini',
58
- :disabled => !can?(:update, <%= var_name %>)
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 var_name %>,
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, <%= var_name %>)
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, <%= local_class_name %>) %>
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' %>