dust-generators 0.2.6 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +18 -6
- data/TODO.txt +5 -0
- data/lib/dust/version.rb +2 -2
- data/lib/generators/dust/albums/USAGE +2 -4
- data/lib/generators/dust/albums/albums_generator.rb +138 -138
- data/lib/generators/dust/albums/templates/app/controllers/albums_controller.rb +18 -18
- data/lib/generators/dust/albums/templates/app/controllers/photos_controller.rb +37 -37
- data/lib/generators/dust/albums/templates/app/controllers/view_albums_controller.rb +9 -9
- data/lib/generators/dust/albums/templates/app/models/album.rb +50 -48
- data/lib/generators/dust/albums/templates/app/models/photo.rb +21 -21
- data/lib/generators/dust/albums/templates/app/views/albums/_form.html.haml +35 -0
- data/lib/generators/dust/albums/templates/app/views/albums/_search.html.haml +4 -0
- data/lib/generators/dust/albums/templates/app/views/albums/_upload_script.html.haml +39 -0
- data/lib/generators/dust/albums/templates/app/views/albums/edit.html.haml +4 -0
- data/lib/generators/dust/albums/templates/app/views/albums/index.html.haml +35 -0
- data/lib/generators/dust/albums/templates/app/views/albums/manage.html.haml +47 -0
- data/lib/generators/dust/albums/templates/app/views/albums/new.html.haml +6 -0
- data/lib/generators/dust/albums/templates/app/views/albums/show.html.haml +42 -0
- data/lib/generators/dust/albums/templates/app/views/albums/show.js.haml +1 -0
- data/lib/generators/dust/albums/templates/app/views/photos/_form.html.haml +17 -0
- data/lib/generators/dust/albums/templates/app/views/photos/_photo.html.haml +22 -0
- data/lib/generators/dust/albums/templates/app/views/photos/_search.html.haml +5 -0
- data/lib/generators/dust/albums/templates/app/views/photos/array.js.haml +3 -0
- data/lib/generators/dust/albums/templates/app/views/photos/edit.html.haml +27 -0
- data/lib/generators/dust/albums/templates/app/views/photos/index.html.haml +85 -0
- data/lib/generators/dust/albums/templates/app/views/photos/new.html.haml +7 -0
- data/lib/generators/dust/albums/templates/app/views/photos/show.html.haml +24 -0
- data/lib/generators/dust/albums/templates/app/views/photos/show.js.haml +10 -0
- data/lib/generators/dust/albums/templates/app/views/view_albums/index.html.haml +25 -0
- data/lib/generators/dust/albums/templates/app/views/view_albums/show.html.haml +32 -0
- data/lib/generators/dust/albums/templates/javascripts/dust_album.js +22 -22
- data/lib/generators/dust/albums/templates/migration/albums_migration.rb +23 -21
- data/lib/generators/dust/albums/templates/stylesheets/dust_album.css +15 -3
- data/lib/generators/dust/albums/templates/stylesheets/dust_album_app.css +54 -3
- data/lib/generators/dust/scaffold/scaffold_generator.rb +20 -20
- data/lib/generators/dust/scaffold/templates/controller.rb +6 -6
- data/lib/generators/dust/scaffold/templates/migration.rb +2 -0
- data/lib/generators/dust/scaffold/templates/model.rb +10 -10
- data/lib/generators/dust/scaffold/templates/view_controller.rb +8 -8
- data/lib/generators/dust/scaffold/templates/views/erb/_search.html.erb +5 -5
- data/lib/generators/dust/scaffold/templates/views/front_end/{index.html.erb → erb/index.html.erb} +6 -6
- data/lib/generators/dust/scaffold/templates/views/front_end/erb/show.html.erb +17 -0
- data/lib/generators/dust/scaffold/templates/views/front_end/haml/index.html.haml +10 -0
- data/lib/generators/dust/scaffold/templates/views/front_end/haml/show.html.haml +15 -0
- data/lib/generators/dust/scaffold/templates/views/haml/_form.html.haml +7 -4
- data/lib/generators/dust/scaffold/templates/views/haml/_search.html.haml +5 -0
- data/lib/generators/dust/scaffold/templates/views/haml/edit.html.haml +1 -11
- data/lib/generators/dust/scaffold/templates/views/haml/index.html.haml +18 -23
- data/lib/generators/dust/scaffold/templates/views/haml/new.html.haml +1 -3
- data/lib/generators/dust/scaffold/templates/views/haml/show.html.haml +15 -13
- data/rails_generators/dust_albums/USAGE +2 -4
- data/rails_generators/dust_config/USAGE +3 -3
- data/rails_generators/dust_scaffold/USAGE +5 -5
- metadata +30 -26
- data/lib/generators/dust/albums/templates/app/views/albums/_form.html.erb +0 -52
- data/lib/generators/dust/albums/templates/app/views/albums/_search.html.erb +0 -6
- data/lib/generators/dust/albums/templates/app/views/albums/_upload_script.html.erb +0 -39
- data/lib/generators/dust/albums/templates/app/views/albums/edit.html.erb +0 -5
- data/lib/generators/dust/albums/templates/app/views/albums/index.html.erb +0 -61
- data/lib/generators/dust/albums/templates/app/views/albums/manage.html.erb +0 -65
- data/lib/generators/dust/albums/templates/app/views/albums/new.html.erb +0 -6
- data/lib/generators/dust/albums/templates/app/views/albums/show.html.erb +0 -56
- data/lib/generators/dust/albums/templates/app/views/albums/show.js.erb +0 -1
- data/lib/generators/dust/albums/templates/app/views/photos/_form.html.erb +0 -23
- data/lib/generators/dust/albums/templates/app/views/photos/_photo.html.erb +0 -25
- data/lib/generators/dust/albums/templates/app/views/photos/_search.html.erb +0 -6
- data/lib/generators/dust/albums/templates/app/views/photos/array.js.erb +0 -3
- data/lib/generators/dust/albums/templates/app/views/photos/edit.html.erb +0 -28
- data/lib/generators/dust/albums/templates/app/views/photos/index.html.erb +0 -85
- data/lib/generators/dust/albums/templates/app/views/photos/new.html.erb +0 -7
- data/lib/generators/dust/albums/templates/app/views/photos/show.html.erb +0 -26
- data/lib/generators/dust/albums/templates/app/views/photos/show.js.erb +0 -9
- data/lib/generators/dust/albums/templates/app/views/view_albums/index.html.erb +0 -31
- data/lib/generators/dust/albums/templates/app/views/view_albums/show.html.erb +0 -31
- data/lib/generators/dust/scaffold/templates/views/front_end/show.html.erb +0 -17
data/README.rdoc
CHANGED
@@ -1,12 +1,24 @@
|
|
1
1
|
= dust-generators
|
2
2
|
|
3
3
|
Collection of generators for the Dust CMS
|
4
|
-
* Albums
|
5
|
-
|
6
|
-
*
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
* Albums - Creates album and photo scaffolds along with uploadify integration
|
5
|
+
* Scaffold - Creates scaffold with views customized for dust admin pages
|
6
|
+
* Config - The dust_config generator creates YAML file in your config directory and an initializer to load this config.
|
7
|
+
|
8
|
+
= Usage
|
9
|
+
|
10
|
+
- Rails 3
|
11
|
+
|
12
|
+
include dust-generators in your Gemfile
|
13
|
+
rails g
|
14
|
+
to view available commands
|
15
|
+
|
16
|
+
- Rails 2
|
17
|
+
script/generate dust_album --help
|
18
|
+
script/generate dust_config --help
|
19
|
+
script/generate dust_scaffold --help
|
20
|
+
|
21
|
+
This will walk you through the various commands
|
10
22
|
|
11
23
|
== Contributing to dust-generators
|
12
24
|
|
data/TODO.txt
ADDED
data/lib/dust/version.rb
CHANGED
@@ -5,141 +5,141 @@ require 'rails/generators/generated_attribute'
|
|
5
5
|
module Dust
|
6
6
|
module Generators
|
7
7
|
class AlbumsGenerator < Base
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
8
|
+
include Rails::Generators::Migration
|
9
|
+
desc "Create all migrations and copy all files for Dust Albums."
|
10
|
+
|
11
|
+
argument :parent_model_name, :type => :string, :required => true, :banner => 'ParentModelName'
|
12
|
+
argument :child_model_name, :type => :string, :required => true, :banner => 'ChildModelName'
|
13
|
+
|
14
|
+
def source_root
|
15
|
+
@source_root ||= File.expand_path('../templates', __FILE__)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_migration
|
19
|
+
migration_template "migration/albums_migration.rb", "db/migrate/create_#{parent_plural_name}.rb"
|
20
|
+
end
|
21
|
+
|
22
|
+
def routes
|
23
|
+
route("match \"all/#{parent_plural_name}\" => \"view_#{parent_plural_name}#index\", :as => :view_#{parent_plural_name}")
|
24
|
+
route("match \"#{child_plural_name}-for/:filename\" => \"view_#{parent_plural_name}#show\", :as => :view_#{parent_singular_name}")
|
25
|
+
route("match \"manage-#{child_plural_name}/:id\" => \"#{parent_plural_name}#manage\", :as => :manage_#{child_plural_name}")
|
26
|
+
route("match \"#{child_plural_name}/array\" => \"#{child_plural_name}#array\", :as => :#{child_plural_name}_sort")
|
27
|
+
route("match \"destroy-#{child_plural_name}\" => \"#{child_plural_name}#destroy\", :as => :#{child_plural_name}_bulk_delete")
|
28
|
+
|
29
|
+
route("resources :#{parent_plural_name}")
|
30
|
+
route("resources :#{child_plural_name}")
|
31
|
+
end
|
32
|
+
|
33
|
+
def app
|
34
|
+
template "app/controllers/albums_controller.rb", "app/controllers/#{parent_plural_name}_controller.rb"
|
35
|
+
template "app/controllers/photos_controller.rb", "app/controllers/#{child_plural_name}_controller.rb"
|
36
|
+
template "app/controllers/view_albums_controller.rb", "app/controllers/view_#{parent_plural_name}_controller.rb"
|
37
|
+
|
38
|
+
template "app/helpers/albums_helper.rb", "app/helpers/#{parent_plural_name}_helper.rb"
|
39
|
+
template "app/helpers/photos_helper.rb", "app/helpers/#{child_plural_name}_helper.rb"
|
40
|
+
template "app/helpers/view_albums_helper.rb", "app/helpers/view_#{parent_plural_name}_helper.rb"
|
41
|
+
|
42
|
+
template "app/models/album.rb", "app/models/#{parent_singular_name}.rb"
|
43
|
+
template "app/models/photo.rb", "app/models/#{child_singular_name}.rb"
|
44
|
+
|
45
|
+
template "app/views/albums/_form.html.haml", "app/views/#{parent_plural_name}/_form.html.haml"
|
46
|
+
template "app/views/albums/_search.html.haml", "app/views/#{parent_plural_name}/_search.html.haml"
|
47
|
+
template "app/views/albums/_upload_script.html.haml", "app/views/#{parent_plural_name}/_upload_script.html.haml"
|
48
|
+
template "app/views/albums/edit.html.haml", "app/views/#{parent_plural_name}/edit.html.haml"
|
49
|
+
template "app/views/albums/index.html.haml", "app/views/#{parent_plural_name}/index.html.haml"
|
50
|
+
template "app/views/albums/manage.html.haml", "app/views/#{parent_plural_name}/manage.html.haml"
|
51
|
+
template "app/views/albums/new.html.haml", "app/views/#{parent_plural_name}/new.html.haml"
|
52
|
+
template "app/views/albums/show.html.haml", "app/views/#{parent_plural_name}/show.html.haml"
|
53
|
+
template "app/views/albums/show.js.haml", "app/views/#{parent_plural_name}/show.js.haml"
|
54
|
+
|
55
|
+
template "app/views/photos/_form.html.haml", "app/views/#{child_plural_name}/_form.html.haml"
|
56
|
+
template "app/views/photos/_search.html.haml", "app/views/#{child_plural_name}/_search.html.haml"
|
57
|
+
template "app/views/photos/_photo.html.haml", "app/views/#{child_plural_name}/_#{child_singular_name}.html.haml"
|
58
|
+
template "app/views/photos/array.js.haml", "app/views/#{child_plural_name}/array.js.haml"
|
59
|
+
template "app/views/photos/edit.html.haml", "app/views/#{child_plural_name}/edit.html.haml"
|
60
|
+
template "app/views/photos/index.html.haml", "app/views/#{child_plural_name}/index.html.haml"
|
61
|
+
template "app/views/photos/new.html.haml", "app/views/#{child_plural_name}/new.html.haml"
|
62
|
+
template "app/views/photos/show.html.haml", "app/views/#{child_plural_name}/show.html.haml"
|
63
|
+
template "app/views/photos/show.js.haml", "app/views/#{child_plural_name}/show.js.haml"
|
64
|
+
|
65
|
+
template "app/views/view_albums/index.html.haml", "app/views/view_#{parent_plural_name}/index.html.haml"
|
66
|
+
template "app/views/view_albums/show.html.haml", "app/views/view_#{parent_plural_name}/show.html.haml"
|
67
|
+
end
|
68
|
+
|
69
|
+
def css
|
70
|
+
template "stylesheets/dust_album.css", "public/stylesheets/dust_#{parent_singular_name}.css"
|
71
|
+
template "stylesheets/uploadify.css", "public/stylesheets/#{parent_singular_name}_uploadify.css"
|
72
|
+
template "stylesheets/dust_album_app.css", "public/stylesheets/dust_#{parent_singular_name}_app.css"
|
73
|
+
end
|
74
|
+
|
75
|
+
def javascript
|
76
|
+
template "javascripts/dragsort.js", "public/javascripts/dragsort.js"
|
77
|
+
template "javascripts/dust_album.js", "public/javascripts/dust_#{parent_singular_name}.js"
|
78
|
+
|
79
|
+
src_dir = File.join(source_root, 'javascripts', 'uploadify')
|
80
|
+
dst_dir = File.join(RAILS_ROOT, 'public', 'javascripts')
|
81
|
+
|
82
|
+
FileUtils.cp_r src_dir, dst_dir, :verbose => true
|
83
|
+
end
|
84
|
+
|
85
|
+
def images
|
86
|
+
template "images/cancel.png", "public/images/cancel.png"
|
87
|
+
template "images/browse.png", "public/images/browse.png"
|
88
|
+
template "images/upload.png", "public/images/upload.png"
|
89
|
+
template "images/save_position.png", "public/images/save_position.png"
|
90
|
+
end
|
91
|
+
|
92
|
+
def initializers
|
93
|
+
template "initializers/flash_session_cookie_middleware.rb", "config/initializers/flash_session_cookie_middleware.rb"
|
94
|
+
template "initializers/session_store_middleware.rb", "config/initializers/session_store_middleware.rb"
|
95
|
+
end
|
96
|
+
|
97
|
+
def rake_migrations
|
98
|
+
rake("db:migrate")
|
99
|
+
end
|
100
|
+
|
101
|
+
#NAMING METHODS
|
102
|
+
def parent
|
103
|
+
parent_model_name.downcase.singularize
|
104
|
+
end
|
105
|
+
|
106
|
+
def child
|
107
|
+
child_model_name.downcase.singularize
|
108
|
+
end
|
109
|
+
|
110
|
+
def parent_singular_name
|
111
|
+
parent.underscore
|
112
|
+
end
|
113
|
+
|
114
|
+
def child_singular_name
|
115
|
+
child.underscore
|
116
|
+
end
|
117
|
+
|
118
|
+
def parent_plural_name
|
119
|
+
parent.underscore.pluralize
|
120
|
+
end
|
121
|
+
|
122
|
+
def child_plural_name
|
123
|
+
child.underscore.pluralize
|
124
|
+
end
|
125
|
+
|
126
|
+
def parent_class_name
|
127
|
+
parent.camelize
|
128
|
+
end
|
129
|
+
|
130
|
+
def child_class_name
|
131
|
+
child.camelize
|
132
|
+
end
|
133
|
+
|
134
|
+
def parent_plural_class_name
|
135
|
+
parent_plural_name.camelize
|
136
|
+
end
|
137
|
+
|
138
|
+
def child_plural_class_name
|
139
|
+
child_plural_name.camelize
|
140
|
+
end
|
141
|
+
|
142
|
+
# FIXME: Should be proxied to ActiveRecord::Generators::Base
|
143
143
|
# Implement the required interface for Rails::Generators::Migration.
|
144
144
|
def self.next_migration_number(dirname) #:nodoc:
|
145
145
|
if ActiveRecord::Base.timestamped_migrations
|
@@ -148,6 +148,6 @@ module Dust
|
|
148
148
|
"%.3d" % (current_migration_number(dirname) + 1)
|
149
149
|
end
|
150
150
|
end
|
151
|
-
|
152
|
-
|
153
|
-
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
class <%=parent_plural_class_name%>Controller < ApplicationController
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
|
3
|
+
filter_resource_access
|
4
|
+
|
5
|
+
layout 'cms'
|
6
|
+
|
7
7
|
def index
|
8
|
-
@<%=parent_plural_name%> = <%=parent_class_name%>.page(params[:search], params[:page])
|
8
|
+
@<%=parent_plural_name%> = <%=parent_class_name%>.roots.page(params[:search], params[:page])
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def show
|
12
12
|
@<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id], :include => :<%=child_plural_name%>)
|
13
|
-
|
13
|
+
@new_<%=child_singular_name%> = <%=child_class_name%>.new(:<%=parent_singular_name%>_id => @<%=parent_singular_name%>.id)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def new
|
17
17
|
@<%=parent_singular_name%> = <%=parent_class_name%>.new
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def create
|
21
21
|
@<%=parent_singular_name%> = <%=parent_class_name%>.new(params[:<%=parent_singular_name%>])
|
22
22
|
if @<%=parent_singular_name%>.save
|
@@ -26,11 +26,11 @@ class <%=parent_plural_class_name%>Controller < ApplicationController
|
|
26
26
|
render :action => 'new'
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def edit
|
31
31
|
@<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id])
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def update
|
35
35
|
@<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id])
|
36
36
|
if @<%=parent_singular_name%>.update_attributes(params[:<%=parent_singular_name%>])
|
@@ -40,7 +40,7 @@ class <%=parent_plural_class_name%>Controller < ApplicationController
|
|
40
40
|
render :action => 'edit'
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def destroy
|
45
45
|
@<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id])
|
46
46
|
@<%=parent_singular_name%>.destroy
|
@@ -48,9 +48,9 @@ class <%=parent_plural_class_name%>Controller < ApplicationController
|
|
48
48
|
redirect_to <%=parent_plural_name%>_url
|
49
49
|
end
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
def manage
|
52
|
+
@<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id], :include => :<%=child_plural_name%>)
|
53
|
+
@<%=child_plural_name%> = @<%=parent_singular_name%>.<%=child_plural_name%>
|
54
|
+
render :layout => false
|
55
|
+
end
|
56
56
|
end
|
@@ -1,27 +1,27 @@
|
|
1
1
|
class <%=child_plural_class_name%>Controller < ApplicationController
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
|
3
|
+
filter_access_to :index, :new, :create, :destroy
|
4
|
+
filter_access_to :edit, :update, :attribute_check => true
|
5
|
+
|
6
|
+
layout 'cms'
|
7
|
+
|
8
8
|
def index
|
9
9
|
@<%=child_plural_name%> = <%=child_class_name%>.page(params[:search], params[:page])
|
10
|
-
|
10
|
+
@<%=child_singular_name%>_<%=parent_plural_name%> = @<%=child_plural_name%>.group_by { |<%=child_singular_name%>| <%=child_singular_name%>.<%=parent_singular_name%>.title }
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def show
|
14
14
|
@<%=child_singular_name%> = <%=child_class_name%>.find(params[:id], :include => :<%=parent_singular_name%>)
|
15
|
-
|
16
|
-
|
15
|
+
@total_uploads = <%=child_class_name%>.find(:all, :conditions => { :<%=parent_singular_name%>_id => @<%=child_singular_name%>.<%=parent_singular_name%>.id})
|
16
|
+
@<%=parent_singular_name%> = @<%=child_singular_name%>.<%=parent_singular_name%>
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def new
|
20
20
|
@<%=child_singular_name%> = <%=child_class_name%>.new
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def create
|
24
|
-
|
24
|
+
newparams = coerce(params)
|
25
25
|
@<%=child_singular_name%> = <%=child_class_name%>.new(newparams[:<%=child_singular_name%>])
|
26
26
|
if @<%=child_singular_name%>.save
|
27
27
|
flash[:notice] = "Successfully created <%=child_singular_name%>."
|
@@ -33,16 +33,16 @@ class <%=child_plural_class_name%>Controller < ApplicationController
|
|
33
33
|
render :action => 'new'
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def edit
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
if params[:edit] == '<%=child_singular_name%>'
|
39
|
+
render :layout => false
|
40
|
+
@<%=child_singular_name%> = <%=child_class_name%>.find(params[:id])
|
41
|
+
else
|
42
|
+
@<%=child_singular_name%> = <%=child_class_name%>.find(params[:id])
|
43
|
+
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def update
|
47
47
|
@<%=child_singular_name%> = <%=child_class_name%>.find(params[:id])
|
48
48
|
if @<%=child_singular_name%>.update_attributes(params[:<%=child_singular_name%>])
|
@@ -52,32 +52,32 @@ class <%=child_plural_class_name%>Controller < ApplicationController
|
|
52
52
|
render :action => 'edit'
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
56
|
-
|
55
|
+
|
56
|
+
def destroy
|
57
57
|
if request.post?
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
58
|
+
if params[:<%=child_singular_name%>_ids]
|
59
|
+
params[:<%=child_singular_name%>_ids].each do |<%=child_singular_name%>|
|
60
|
+
@<%=child_singular_name%> = <%=child_class_name%>.find <%=child_singular_name%>
|
61
|
+
@<%=child_singular_name%>.destroy
|
62
|
+
end
|
63
|
+
flash[:notice] = "<%=child_plural_class_name%> Successfully deleted!"
|
64
|
+
end
|
65
|
+
redirect_to(<%=parent_singular_name%>_path(@<%=child_singular_name%>.<%=parent_singular_name%>))
|
66
|
+
end
|
67
67
|
end
|
68
68
|
|
69
|
-
|
70
|
-
|
69
|
+
def array
|
70
|
+
menu_sort(params[:ul])
|
71
71
|
flash[:notice] = "Successfully Sorted <%=child_plural_class_name%>."
|
72
|
-
|
72
|
+
end
|
73
73
|
|
74
|
-
|
74
|
+
private
|
75
75
|
def coerce(params)
|
76
76
|
if params[:<%=child_singular_name%>].nil?
|
77
77
|
h = Hash.new
|
78
78
|
h[:<%=child_singular_name%>] = Hash.new
|
79
79
|
h[:<%=child_singular_name%>][:<%=parent_singular_name%>_id] = params[:<%=parent_singular_name%>_id]
|
80
|
-
|
80
|
+
h[:<%=child_singular_name%>][:title] = params[:title]
|
81
81
|
h[:<%=child_singular_name%>][:file] = params[:Filedata]
|
82
82
|
h[:<%=child_singular_name%>][:file].content_type = MIME::Types.type_for(h[:<%=child_singular_name%>][:file].original_filename).to_s
|
83
83
|
h
|
@@ -1,17 +1,17 @@
|
|
1
1
|
class View<%=parent_plural_class_name%>Controller < ApplicationController
|
2
|
-
|
2
|
+
|
3
3
|
def index
|
4
|
-
|
4
|
+
@<%=parent_plural_name%> = <%=parent_class_name%>.view(params[:page])
|
5
5
|
end
|
6
6
|
|
7
7
|
def show
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
if <%=parent_class_name%>.find_by_filename(params[:filename]) == nil
|
9
|
+
@<%=parent_singular_name%> = <%=parent_class_name%>.find(:first)
|
10
|
+
render :file => "#{RAILS_ROOT}/public/404.html", :layout => false, :status => 404
|
11
|
+
else
|
12
|
+
@<%=parent_singular_name%> = <%=parent_class_name%>.find_by_filename(params[:filename])
|
13
|
+
@<%=child_plural_name%> = @<%=parent_singular_name%>.<%=child_plural_name%>.<%=parent_singular_name%>_page(params[:page])
|
14
|
+
end
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|