stager 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -98,7 +98,7 @@ module Stager
98
98
 
99
99
  def create_presenter
100
100
  unless options[:skip_presenter]
101
- run "rails g exhibit:presenter #{scaffold_name} #{@namespaced_model ? nil : "--no_namespace"}"
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.#{view_language}")
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,5 +1,4 @@
1
1
  def destroy
2
- @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
2
  @<%= instance_name %>.destroy
4
3
  redirect_to(<%= items_url %>, :notice => "Successfully destroyed <%= class_name.underscore.humanize.downcase %>.")
5
4
  end
@@ -1,3 +1,2 @@
1
1
  def edit
2
- @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
2
  end
@@ -1,3 +1,2 @@
1
1
  def show
2
- @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
2
  end
@@ -1,5 +1,4 @@
1
1
  def update
2
- @<%= instance_name %> = <%= class_name %>.find(params[:id])
3
2
  if @<%= instance_name %>.update_attributes(params[:<%= instance_name %>])
4
3
  redirect_to(<%= item_url %>, :notice => "Successfully updated <%= class_name.underscore.humanize.downcase %>.")
5
4
  else
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Stager
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.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-08 00:00:00 +02:00
18
+ date: 2011-10-10 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency