twilson63-nifty-generators 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/nifty-generators.gemspec +1 -1
- data/rails_generators/nifty_scaffold/nifty_scaffold_generator.rb +15 -3
- data/rails_generators/nifty_scaffold/templates/actions/create.rb +11 -5
- data/rails_generators/nifty_scaffold/templates/actions/edit.rb +5 -0
- data/rails_generators/nifty_scaffold/templates/actions/new.rb +5 -0
- data/rails_generators/nifty_scaffold/templates/actions/update.rb +11 -5
- metadata +1 -1
data/nifty-generators.gemspec
CHANGED
@@ -80,9 +80,21 @@ class NiftyScaffoldGenerator < Rails::Generator::Base
|
|
80
80
|
m.template "views/#{view_language}/_form.html.#{view_language}", "app/views/#{plural_name}/_form.html.#{view_language}"
|
81
81
|
end
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
if options[:haml]
|
84
|
+
m.template "views/#{view_language}/_items.html.#{view_language}", "app/views/#{plural_name}/_#{plural_name}.html.#{view_language}"
|
85
|
+
m.template "views/#{view_language}/_item.html.#{view_language}", "app/views/#{plural_name}/_#{singular_name}.html.#{view_language}"
|
86
|
+
end
|
87
|
+
|
88
|
+
if options[:haml] and options[:ajaxify]
|
89
|
+
m.template "views/#{view_language}/_error.html.#{view_language}", "app/views/#{plural_name}/_error.html.#{view_language}"
|
90
|
+
m.template "views/#{view_language}/error.rjs", "app/views/#{plural_name}/error.rjs"
|
91
|
+
|
92
|
+
m.template "views/#{view_language}/create.rjs", "app/views/#{plural_name}/create.rjs"
|
93
|
+
m.template "views/#{view_language}/update.rjs", "app/views/#{plural_name}/update.rjs"
|
94
|
+
m.template "views/#{view_language}/dialog.rjs", "app/views/#{plural_name}/dialog.rjs"
|
95
|
+
|
96
|
+
end
|
97
|
+
|
86
98
|
m.route_resources plural_name
|
87
99
|
|
88
100
|
if rspec?
|
@@ -1,9 +1,15 @@
|
|
1
1
|
def create
|
2
2
|
@<%= singular_name %> = <%= class_name %>.new(params[:<%= singular_name %>])
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
respond_to do |wants|
|
4
|
+
if @<%= singular_name %>.save
|
5
|
+
wants.html do
|
6
|
+
flash[:notice] = "Successfully created <%= name.humanize.downcase %>."
|
7
|
+
redirect_to <%= item_path('url') %>
|
8
|
+
end
|
9
|
+
wants.js
|
10
|
+
else
|
11
|
+
wants.html { render :action => 'new' }
|
12
|
+
wants.js { render :action => 'error' }
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|
@@ -1,9 +1,15 @@
|
|
1
1
|
def update
|
2
2
|
@<%= singular_name %> = <%= class_name %>.find(params[:id])
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
respond_to do |wants|
|
4
|
+
if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
|
5
|
+
wants.html do
|
6
|
+
flash[:notice] = "Successfully updated <%= name.humanize.downcase %>."
|
7
|
+
redirect_to <%= item_path('url') %>
|
8
|
+
end
|
9
|
+
wants.js
|
10
|
+
else
|
11
|
+
wants.html { render :action => 'edit' }
|
12
|
+
wants.js { render :action => 'error' }
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|