dust-generators 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. data/lib/dust/version.rb +2 -2
  2. data/rails_generators/dust_albums/dust_albums_generator.rb +98 -32
  3. data/rails_generators/dust_albums/templates/app/controllers/albums_controller.rb +20 -20
  4. data/rails_generators/dust_albums/templates/app/controllers/photos_controller.rb +32 -32
  5. data/rails_generators/dust_albums/templates/app/controllers/view_albums_controller.rb +6 -6
  6. data/rails_generators/dust_albums/templates/app/helpers/albums_helper.rb +1 -1
  7. data/rails_generators/dust_albums/templates/app/helpers/photos_helper.rb +1 -1
  8. data/rails_generators/dust_albums/templates/app/helpers/view_albums_helper.rb +1 -1
  9. data/rails_generators/dust_albums/templates/app/models/album.rb +4 -4
  10. data/rails_generators/dust_albums/templates/app/models/photo.rb +4 -4
  11. data/rails_generators/dust_albums/templates/app/views/albums/_form.html.erb +17 -17
  12. data/rails_generators/dust_albums/templates/app/views/albums/_search.html.erb +4 -4
  13. data/rails_generators/dust_albums/templates/app/views/albums/_upload_script.html.erb +11 -11
  14. data/rails_generators/dust_albums/templates/app/views/albums/edit.html.erb +3 -3
  15. data/rails_generators/dust_albums/templates/app/views/albums/index.html.erb +23 -23
  16. data/rails_generators/dust_albums/templates/app/views/albums/manage.html.erb +16 -16
  17. data/rails_generators/dust_albums/templates/app/views/albums/new.html.erb +3 -3
  18. data/rails_generators/dust_albums/templates/app/views/albums/show.html.erb +21 -21
  19. data/rails_generators/dust_albums/templates/app/views/albums/show.js.erb +1 -1
  20. data/rails_generators/dust_albums/templates/app/views/photos/_form.html.erb +9 -9
  21. data/rails_generators/dust_albums/templates/app/views/photos/_photo.html.erb +8 -8
  22. data/rails_generators/dust_albums/templates/app/views/photos/_search.html.erb +4 -4
  23. data/rails_generators/dust_albums/templates/app/views/photos/array.js.erb +1 -1
  24. data/rails_generators/dust_albums/templates/app/views/photos/edit.html.erb +6 -6
  25. data/rails_generators/dust_albums/templates/app/views/photos/index.html.erb +24 -24
  26. data/rails_generators/dust_albums/templates/app/views/photos/new.html.erb +4 -4
  27. data/rails_generators/dust_albums/templates/app/views/photos/show.html.erb +9 -9
  28. data/rails_generators/dust_albums/templates/app/views/photos/show.js.erb +2 -2
  29. data/rails_generators/dust_albums/templates/app/views/view_albums/index.html.erb +16 -16
  30. data/rails_generators/dust_albums/templates/app/views/view_albums/show.html.erb +19 -19
  31. data/rails_generators/dust_albums/templates/javascript/dust_album.js +3 -3
  32. data/rails_generators/dust_albums/templates/migration/albums_migration.rb +9 -8
  33. data/rails_generators/dust_albums/templates/stylesheets/dust_album.css +6 -6
  34. data/rails_generators/dust_albums/templates/stylesheets/dust_album_app.css +4 -4
  35. data/rails_generators/dust_albums/templates/stylesheets/uploadify.css +1 -1
  36. metadata +5 -5
data/lib/dust/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  class Dust
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 1
5
- PATCH = 9
4
+ MINOR = 2
5
+ PATCH = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -1,5 +1,13 @@
1
1
  class DustAlbumsGenerator < Rails::Generator::Base
2
2
 
3
+ attr_accessor :parent, :child
4
+
5
+ def initialize(runtime_args, runtime_options = {})
6
+ super
7
+ @parent = @args.first || 'album'
8
+ @child = @args.last || 'photo'
9
+ end
10
+
3
11
  def manifest
4
12
  record do |m|
5
13
  app(m)
@@ -15,40 +23,57 @@ class DustAlbumsGenerator < Rails::Generator::Base
15
23
  end
16
24
 
17
25
  def app(m)
18
- m.template "app/controllers/albums_controller.rb", "app/controllers/albums_controller.rb"
19
- m.template "app/controllers/photos_controller.rb", "app/controllers/photos_controller.rb"
20
- m.template "app/controllers/view_albums_controller.rb", "app/controllers/view_albums_controller.rb"
26
+ m.template "app/controllers/albums_controller.rb", "app/controllers/#{parent_plural_name}_controller.rb"
27
+ m.template "app/controllers/photos_controller.rb", "app/controllers/#{child_plural_name}_controller.rb"
28
+ m.template "app/controllers/view_albums_controller.rb", "app/controllers/view_#{parent_plural_name}_controller.rb"
21
29
 
22
- m.template "app/helpers/albums_helper.rb", "app/helpers/albums_helper.rb"
23
- m.template "app/helpers/photos_helper.rb", "app/helpers/photos_helper.rb"
24
- m.template "app/helpers/view_albums_helper.rb", "app/helpers/view_albums_helper.rb"
30
+ m.template "app/helpers/albums_helper.rb", "app/helpers/#{parent_plural_name}_helper.rb"
31
+ m.template "app/helpers/photos_helper.rb", "app/helpers/#{child_plural_name}_helper.rb"
32
+ m.template "app/helpers/view_albums_helper.rb", "app/helpers/view_#{parent_plural_name}_helper.rb"
25
33
 
26
- m.template "app/models/album.rb", "app/models/album.rb"
27
- m.template "app/models/photo.rb", "app/models/photo.rb"
34
+ m.template "app/models/album.rb", "app/models/#{parent_singular_name}.rb"
35
+ m.template "app/models/photo.rb", "app/models/#{child_singular_name}.rb"
28
36
 
29
- photos_dir = File.join(@source_root, 'app', 'views', 'photos')
30
- albums_dir = File.join(@source_root, 'app', 'views', 'albums')
31
- view_albums_dir = File.join(@source_root, 'app', 'views', 'view_albums')
32
- dst_dir = File.join(RAILS_ROOT, 'app', 'views')
33
-
34
- FileUtils.cp_r photos_dir, dst_dir, :verbose => true
35
- FileUtils.cp_r albums_dir, dst_dir, :verbose => true
36
- FileUtils.cp_r view_albums_dir, dst_dir, :verbose => true
37
+ m.directory "app/views/#{parent_plural_name}"
38
+ m.template "app/views/albums/_form.html.erb", "app/views/#{parent_plural_name}/_form.html.erb"
39
+ m.template "app/views/albums/_search.html.erb", "app/views/#{parent_plural_name}/_search.html.erb"
40
+ m.template "app/views/albums/_upload_script.html.erb", "app/views/#{parent_plural_name}/_upload_script.html.erb"
41
+ m.template "app/views/albums/edit.html.erb", "app/views/#{parent_plural_name}/edit.html.erb"
42
+ m.template "app/views/albums/index.html.erb", "app/views/#{parent_plural_name}/index.html.erb"
43
+ m.template "app/views/albums/manage.html.erb", "app/views/#{parent_plural_name}/manage.html.erb"
44
+ m.template "app/views/albums/new.html.erb", "app/views/#{parent_plural_name}/new.html.erb"
45
+ m.template "app/views/albums/show.html.erb", "app/views/#{parent_plural_name}/show.html.erb"
46
+ m.template "app/views/albums/show.js.erb", "app/views/#{parent_plural_name}/show.js.erb"
47
+
48
+ m.directory "app/views/#{child_plural_name}"
49
+ m.template "app/views/photos/_form.html.erb", "app/views/#{child_plural_name}/_form.html.erb"
50
+ m.template "app/views/photos/_search.html.erb", "app/views/#{child_plural_name}/_search.html.erb"
51
+ m.template "app/views/photos/_photo.html.erb", "app/views/#{child_plural_name}/_#{child_singular_name}.html.erb"
52
+ m.template "app/views/photos/array.js.erb", "app/views/#{child_plural_name}/array.js.erb"
53
+ m.template "app/views/photos/edit.html.erb", "app/views/#{child_plural_name}/edit.html.erb"
54
+ m.template "app/views/photos/index.html.erb", "app/views/#{child_plural_name}/index.html.erb"
55
+ m.template "app/views/photos/new.html.erb", "app/views/#{child_plural_name}/new.html.erb"
56
+ m.template "app/views/photos/show.html.erb", "app/views/#{child_plural_name}/show.html.erb"
57
+ m.template "app/views/photos/show.js.erb", "app/views/#{child_plural_name}/show.js.erb"
58
+
59
+ m.directory "app/views/view_#{parent_plural_name}"
60
+ m.template "app/views/view_albums/index.html.erb", "app/views/view_#{parent_plural_name}/index.html.erb"
61
+ m.template "app/views/view_albums/show.html.erb", "app/views/view_#{parent_plural_name}/show.html.erb"
37
62
  end
38
63
 
39
64
  def migrations(m)
40
- m.migration_template "migration/albums_migration.rb", "db/migrate", :migration_file_name => "create_albums"
65
+ m.migration_template "migration/albums_migration.rb", "db/migrate", :migration_file_name => "create_#{parent_plural_name}"
41
66
  end
42
67
 
43
68
  def css(m)
44
- m.template "stylesheets/dust_album.css", "public/stylesheets/dust_album.css"
69
+ m.template "stylesheets/dust_album.css", "public/stylesheets/dust_#{parent_singular_name}.css"
45
70
  m.template "stylesheets/uploadify.css", "public/stylesheets/uploadify.css"
46
- m.template "stylesheets/dust_album_app.css", "public/stylesheets/dust_album_app.css"
71
+ m.template "stylesheets/dust_album_app.css", "public/stylesheets/dust_#{parent_singular_name}_app.css"
47
72
  end
48
73
 
49
74
  def javascript(m)
50
75
  m.template "javascript/dragsort.js", "public/javascripts/dragsort.js"
51
- m.template "javascript/dust_album.js", "public/javascripts/dust_album.js"
76
+ m.template "javascript/dust_album.js", "public/javascripts/dust_#{parent_singular_name}.js"
52
77
 
53
78
  src_dir = File.join(@source_root, 'javascript', 'uploadify')
54
79
  dst_dir = File.join(RAILS_ROOT, 'public', 'javascripts')
@@ -69,23 +94,64 @@ class DustAlbumsGenerator < Rails::Generator::Base
69
94
  end
70
95
 
71
96
  def routes(m)
72
- m.route :name => 'view_albums',
73
- :url => 'all/albums',
74
- :controller => 'view_albums',
97
+ m.route :name => "view_#{parent_plural_name}",
98
+ :url => "all/#{parent_plural_name}",
99
+ :controller => "view_#{parent_plural_name}",
75
100
  :action => 'index'
76
- m.route :name => 'view_album',
77
- :url => 'photos-for/:filename',
78
- :controller => 'view_albums',
101
+ m.route :name => "view_#{parent_singular_name}",
102
+ :url => "#{child_plural_name}-for/:filename",
103
+ :controller => "view_#{parent_plural_name}",
79
104
  :action => 'show'
80
- m.route :name => 'manage_photos',
81
- :url => 'manage-photos/:id',
82
- :controller => 'albums',
105
+ m.route :name => "manage_#{child_plural_name}",
106
+ :url => "manage-#{child_plural_name}/:id",
107
+ :controller => "#{parent_plural_name}",
83
108
  :action => 'manage'
84
109
 
85
- m.route_resources 'photos'
86
- m.route_resources 'albums'
110
+ m.route_resources "#{child_plural_name}"
111
+ m.route_resources "#{parent_plural_name}"
112
+ end
113
+
114
+ #NAMING METHODS
115
+ def parent_singular_name
116
+ parent.underscore
87
117
  end
118
+
119
+ def child_singular_name
120
+ child.underscore
121
+ end
122
+
123
+ def parent_plural_name
124
+ parent.underscore.pluralize
125
+ end
126
+
127
+ def child_plural_name
128
+ child.underscore.pluralize
129
+ end
130
+
131
+ def parent_class_name
132
+ parent.camelize
133
+ end
134
+
135
+ def child_class_name
136
+ child.camelize
137
+ end
88
138
 
139
+ def parent_plural_class_name
140
+ parent_plural_name.camelize
141
+ end
142
+
143
+ def child_plural_class_name
144
+ child_plural_name.camelize
145
+ end
146
+
147
+ def banner
148
+ <<-EOS
149
+ Creates two albums and photos with any given naming convention.
150
+
151
+ USAGE: #{$0} #{spec.name} parent_name (i.e. albums) child_name (i.e. photos)
152
+ EOS
153
+ end
154
+
89
155
  end
90
156
 
91
157
  module Rails
@@ -101,7 +167,7 @@ module Rails
101
167
  # Here's a readable version of the long string used above in route_code;
102
168
  # but it should be kept on one line to avoid inserting extra whitespace
103
169
  # into routes.rb when the generator is run:
104
- # "map.#{route_options[:name]} '#{route_options[:name]}',
170
+ # "map.#{route_options[:name]} '#{route_options[:url]}',
105
171
  # :controller => '#{route_options[:controller]}',
106
172
  # :action => '#{route_options[:action]}'"
107
173
 
@@ -1,56 +1,56 @@
1
- class AlbumsController < ApplicationController
1
+ class <%=parent_plural_class_name%>Controller < ApplicationController
2
2
 
3
3
  filter_resource_access
4
4
 
5
5
  layout 'cms'
6
6
 
7
7
  def index
8
- @albums = Album.page(params[:search], params[:page])
8
+ @<%=parent_plural_name%> = <%=parent_class_name%>.page(params[:search], params[:page])
9
9
  end
10
10
 
11
11
  def show
12
- @album = Album.find(params[:id], :include => :photos)
13
- @new_photo = Photo.new(:album_id => @album.id)
12
+ @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id], :include => :<%=child_plural_name%>)
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
- @album = Album.new
17
+ @<%=parent_singular_name%> = <%=parent_class_name%>.new
18
18
  end
19
19
 
20
20
  def create
21
- @album = Album.new(params[:album])
22
- if @album.save
23
- flash[:notice] = "Successfully created album."
24
- redirect_to @album
21
+ @<%=parent_singular_name%> = <%=parent_class_name%>.new(params[:<%=parent_singular_name%>])
22
+ if @<%=parent_singular_name%>.save
23
+ flash[:notice] = "Successfully created <%=parent_singular_name%>."
24
+ redirect_to @<%=parent_singular_name%>
25
25
  else
26
26
  render :action => 'new'
27
27
  end
28
28
  end
29
29
 
30
30
  def edit
31
- @album = Album.find(params[:id])
31
+ @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id])
32
32
  end
33
33
 
34
34
  def update
35
- @album = Album.find(params[:id])
36
- if @album.update_attributes(params[:album])
37
- flash[:notice] = "Successfully updated album."
38
- redirect_to view_album_path(@album.filename)
35
+ @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id])
36
+ if @<%=parent_singular_name%>.update_attributes(params[:<%=parent_singular_name%>])
37
+ flash[:notice] = "Successfully updated <%=parent_singular_name%>."
38
+ redirect_to view_<%=parent_singular_name%>_path(@<%=parent_singular_name%>.filename)
39
39
  else
40
40
  render :action => 'edit'
41
41
  end
42
42
  end
43
43
 
44
44
  def destroy
45
- @album = Album.find(params[:id])
46
- @album.destroy
47
- flash[:notice] = "Successfully destroyed album."
48
- redirect_to albums_url
45
+ @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id])
46
+ @<%=parent_singular_name%>.destroy
47
+ flash[:notice] = "Successfully destroyed <%=parent_singular_name%>."
48
+ redirect_to <%=parent_plural_name%>_url
49
49
  end
50
50
 
51
51
  def manage
52
- @album = Album.find(params[:id], :include => :photos)
53
- @photos = @album.photos
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
54
  render :layout => false
55
55
  end
56
56
  end
@@ -1,4 +1,4 @@
1
- class PhotosController < ApplicationController
1
+ class <%=child_plural_class_name%>Controller < ApplicationController
2
2
 
3
3
  filter_access_to :index, :new, :create, :destroy
4
4
  filter_access_to :edit, :update, :attribute_check => true
@@ -6,28 +6,28 @@ class PhotosController < ApplicationController
6
6
  layout 'cms'
7
7
 
8
8
  def index
9
- @photos = Photo.page(params[:search], params[:page])
10
- @photo_albums = @photos.group_by { |photo| [photo.album.title] }
9
+ @<%=child_plural_name%> = <%=child_class_name%>.page(params[:search], params[:page])
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
- @photo = Photo.find(params[:id], :include => :album)
15
- @total_uploads = Photo.find(:all, :conditions => { :album_id => @photo.album.id})
16
- @album = @photo.album
14
+ @<%=child_singular_name%> = <%=child_class_name%>.find(params[:id], :include => :<%=parent_singular_name%>)
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
- @photo = Photo.new
20
+ @<%=child_singular_name%> = <%=child_class_name%>.new
21
21
  end
22
22
 
23
23
  def create
24
24
  newparams = coerce(params)
25
- @photo = Photo.new(newparams[:photo])
26
- if @photo.save
27
- flash[:notice] = "Successfully created photo."
25
+ @<%=child_singular_name%> = <%=child_class_name%>.new(newparams[:<%=child_singular_name%>])
26
+ if @<%=child_singular_name%>.save
27
+ flash[:notice] = "Successfully created <%=child_singular_name%>."
28
28
  respond_to do |format|
29
- format.html { redirect_to @photo.album }
30
- format.json { render :json => { :result => 'success', :photo => photo_url(@photo) } }
29
+ format.html { redirect_to @<%=child_singular_name%>.<%=parent_singular_name%> }
30
+ format.json { render :json => { :result => 'success', :<%=child_singular_name%> => <%=child_singular_name%>_url(@<%=child_singular_name%>) } }
31
31
  end
32
32
  else
33
33
  render :action => 'new'
@@ -35,19 +35,19 @@ class PhotosController < ApplicationController
35
35
  end
36
36
 
37
37
  def edit
38
- if params[:edit] == 'photo'
38
+ if params[:edit] == '<%=child_singular_name%>'
39
39
  render :layout => false
40
- @photo = Photo.find(params[:id])
40
+ @<%=child_singular_name%> = <%=child_class_name%>.find(params[:id])
41
41
  else
42
- @photo = Photo.find(params[:id])
42
+ @<%=child_singular_name%> = <%=child_class_name%>.find(params[:id])
43
43
  end
44
44
  end
45
45
 
46
46
  def update
47
- @photo = Photo.find(params[:id])
48
- if @photo.update_attributes(params[:photo])
49
- flash[:notice] = "Successfully updated photo."
50
- redirect_to album_url(@photo.album)
47
+ @<%=child_singular_name%> = <%=child_class_name%>.find(params[:id])
48
+ if @<%=child_singular_name%>.update_attributes(params[:<%=child_singular_name%>])
49
+ flash[:notice] = "Successfully updated <%=child_singular_name%>."
50
+ redirect_to <%=parent_singular_name%>_url(@<%=child_singular_name%>.<%=parent_singular_name%>)
51
51
  else
52
52
  render :action => 'edit'
53
53
  end
@@ -55,31 +55,31 @@ class PhotosController < ApplicationController
55
55
 
56
56
  def destroy
57
57
  if request.post?
58
- if params[:photo_ids]
59
- params[:photo_ids].each do |photo|
60
- @photo = Photo.find photo
61
- @photo.destroy
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
62
  end
63
- flash[:notice] = "Photos Successfully deleted!"
63
+ flash[:notice] = "<%=child_plural_class_name%> Successfully deleted!"
64
64
  end
65
- redirect_to(album_path(@photo.album))
65
+ redirect_to(<%=parent_singular_name%>_path(@<%=child_singular_name%>.<%=parent_singular_name%>))
66
66
  end
67
67
  end
68
68
 
69
69
  def array
70
70
  menu_sort(params[:ul])
71
- flash[:notice] = "Successfully Sorted Photos."
71
+ flash[:notice] = "Successfully Sorted <%=child_plural_class_name%>."
72
72
  end
73
73
 
74
74
  private
75
75
  def coerce(params)
76
- if params[:photo].nil?
76
+ if params[:<%=child_singular_name%>].nil?
77
77
  h = Hash.new
78
- h[:photo] = Hash.new
79
- h[:photo][:album_id] = params[:album_id]
80
- h[:photo][:title] = params[:title]
81
- h[:photo][:file] = params[:Filedata]
82
- h[:photo][:file].content_type = MIME::Types.type_for(h[:photo][:file].original_filename).to_s
78
+ h[:<%=child_singular_name%>] = Hash.new
79
+ h[:<%=child_singular_name%>][:<%=parent_singular_name%>_id] = params[:<%=parent_singular_name%>_id]
80
+ h[:<%=child_singular_name%>][:title] = params[:title]
81
+ h[:<%=child_singular_name%>][:file] = params[:Filedata]
82
+ h[:<%=child_singular_name%>][:file].content_type = MIME::Types.type_for(h[:<%=child_singular_name%>][:file].original_filename).to_s
83
83
  h
84
84
  else
85
85
  params
@@ -1,16 +1,16 @@
1
- class ViewAlbumsController < ApplicationController
1
+ class View<%=parent_plural_class_name%>Controller < ApplicationController
2
2
 
3
3
  def index
4
- @albums = Album.page(params[:search], params[:page])
4
+ @<%=parent_plural_name%> = <%=parent_class_name%>.page(params[:search], params[:page])
5
5
  end
6
6
 
7
7
  def show
8
- if Album.find_by_filename(params[:filename]) == nil
9
- @album = Album.find(:first)
8
+ if <%=parent_class_name%>.find_by_filename(params[:filename]) == nil
9
+ @<%=parent_singular_name%> = <%=parent_class_name%>.find(:first)
10
10
  render :file => "#{RAILS_ROOT}/public/404.html", :layout => false, :status => 404
11
11
  else
12
- @album = Album.find_by_filename(params[:filename])
13
- @photos = @album.photos.album_page(params[:page])
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
14
  end
15
15
  end
16
16
 
@@ -1,2 +1,2 @@
1
- module AlbumsHelper
1
+ module <%=parent_plural_class_name%>Helper
2
2
  end
@@ -1,2 +1,2 @@
1
- module PhotosHelper
1
+ module <%=child_plural_class_name%>Helper
2
2
  end
@@ -1,2 +1,2 @@
1
- module ViewAlbumsHelper
1
+ module View<%=parent_plural_class_name%>Helper
2
2
  end
@@ -1,6 +1,6 @@
1
- class Album < ActiveRecord::Base
1
+ class <%=parent_class_name%> < ActiveRecord::Base
2
2
 
3
- has_many :photos, :dependent => :destroy
3
+ has_many :<%=child_plural_name%>, :dependent => :destroy
4
4
 
5
5
  validates_presence_of :title
6
6
  validates_presence_of :filename
@@ -24,7 +24,7 @@ class Album < ActiveRecord::Base
24
24
  else
25
25
  @menu_item.update_attributes(
26
26
  :title => self.nav,
27
- :url => "/photos-for/#{self.filename}",
27
+ :url => "/<%=child_plural_name%>-for/#{self.filename}",
28
28
  :active => self.active
29
29
  )
30
30
  end
@@ -33,7 +33,7 @@ class Album < ActiveRecord::Base
33
33
  def create_menu_item
34
34
  @menu_item = self.build_menu_item(
35
35
  :title => self.nav,
36
- :url => "/photos-for/#{self.filename}",
36
+ :url => "/<%=child_plural_name%>-for/#{self.filename}",
37
37
  :active => self.active
38
38
  )
39
39
  @menu_item.save
@@ -1,10 +1,10 @@
1
- class Photo < ActiveRecord::Base
1
+ class <%=child_class_name%> < ActiveRecord::Base
2
2
 
3
3
  acts_as_nested_set
4
4
 
5
- belongs_to :album
5
+ belongs_to :<%=parent_singular_name%>
6
6
  has_attached_file :file, :styles => {:large => '800>', :medium => "300x300>", :thumb => "100x100#" }
7
- validates_presence_of :album
7
+ validates_presence_of :<%=parent_singular_name%>
8
8
 
9
9
  def self.page(search, page)
10
10
  paginate :per_page => 24, :page => page,
@@ -12,7 +12,7 @@ class Photo < ActiveRecord::Base
12
12
  :conditions => ["title LIKE ?", "%#{search}%"]
13
13
  end
14
14
 
15
- def self.album_page(page)
15
+ def self.<%=parent_singular_name%>_page(page)
16
16
  roots.paginate :per_page => 24, :page => page
17
17
  end
18
18
  end