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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{nifty-generators}
5
- s.version = "0.2.5"
5
+ s.version = "0.2.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ryan Bates"]
@@ -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
- m.template "views/#{view_language}/_items.html.#{view_language}", "app/views/#{plural_name}/_#{plural_name}.html.#{view_language}"
84
- m.template "views/#{view_language}/_item.html.#{view_language}", "app/views/#{plural_name}/_#{singular_name}.html.#{view_language}"
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
- if @<%= singular_name %>.save
4
- flash[:notice] = "Successfully created <%= name.humanize.downcase %>."
5
- redirect_to <%= item_path('url') %>
6
- else
7
- render :action => 'new'
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,3 +1,8 @@
1
1
  def edit
2
2
  @<%= singular_name %> = <%= class_name %>.find(params[:id])
3
+ respond_to do |wants|
4
+ wants.html
5
+ wants.js { render :action => "dialog" }
6
+ end
7
+
3
8
  end
@@ -1,3 +1,8 @@
1
1
  def new
2
2
  @<%= singular_name %> = <%= class_name %>.new
3
+ respond_to do |wants|
4
+ wants.html
5
+ wants.js { render :action => "dialog" }
6
+ end
7
+
3
8
  end
@@ -1,9 +1,15 @@
1
1
  def update
2
2
  @<%= singular_name %> = <%= class_name %>.find(params[:id])
3
- if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
4
- flash[:notice] = "Successfully updated <%= name.humanize.downcase %>."
5
- redirect_to <%= item_path('url') %>
6
- else
7
- render :action => 'edit'
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilson63-nifty-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bates