stager 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/generators/stager/scaffold/scaffold_generator.rb +14 -2
- data/lib/generators/stager/scaffold/templates/actions/destroy.rb +0 -1
- data/lib/generators/stager/scaffold/templates/actions/edit.rb +0 -1
- data/lib/generators/stager/scaffold/templates/actions/show.rb +0 -1
- data/lib/generators/stager/scaffold/templates/actions/update.rb +0 -1
- data/lib/generators/stager/scaffold/templates/controller.rb +12 -0
- data/lib/stager/version.rb +1 -1
- metadata +4 -4
@@ -98,7 +98,7 @@ module Stager
|
|
98
98
|
|
99
99
|
def create_presenter
|
100
100
|
unless options[:skip_presenter]
|
101
|
-
|
101
|
+
invoke "exhibit:presenter", [scaffold_name, @namespaced_model ? nil : "--no_namespace"]
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -142,7 +142,7 @@ module Stager
|
|
142
142
|
if form_partial?
|
143
143
|
"= render(\"form\")"
|
144
144
|
else
|
145
|
-
read_template("views/_form.html
|
145
|
+
read_template("views/_form.html.haml")
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
@@ -152,6 +152,18 @@ module Stager
|
|
152
152
|
end.join("\n").strip
|
153
153
|
end
|
154
154
|
|
155
|
+
def before_filter_actions
|
156
|
+
controller_actions.map { |action| %w(show edit update destroy).include?(action) ? ":#{action}" : nil }.compact.join(", ")
|
157
|
+
end
|
158
|
+
|
159
|
+
def before_filter_actions?
|
160
|
+
available = false
|
161
|
+
%w(show edit update destroy).each do |name|
|
162
|
+
available = true if action?(name)
|
163
|
+
end
|
164
|
+
available
|
165
|
+
end
|
166
|
+
|
155
167
|
def item_resource
|
156
168
|
scaffold_name.underscore.gsub('/','_')
|
157
169
|
end
|
@@ -1,3 +1,15 @@
|
|
1
1
|
class <%= plural_class_name %>Controller < ApplicationController
|
2
|
+
<%- if before_filter_actions? -%>
|
3
|
+
before_filter :find_<%= singular_name %>, :only => [<%= before_filter_actions %>]
|
4
|
+
<%- end -%>
|
5
|
+
|
2
6
|
<%= controller_methods :actions %>
|
7
|
+
|
8
|
+
<%- if before_filter_actions? -%>
|
9
|
+
private
|
10
|
+
|
11
|
+
def find_<%= singular_name %>
|
12
|
+
@<%= instance_name %> = <%= class_name %>.find(params[:id])
|
13
|
+
end
|
14
|
+
<%- end -%>
|
3
15
|
end
|
data/lib/stager/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Robin Brouwer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-10 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|