media_magick 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.gitignore +2 -1
  2. data/CHANGELOG.md +53 -1
  3. data/Gemfile +0 -2
  4. data/Guardfile +5 -0
  5. data/LICENSE +1 -1
  6. data/README.md +32 -22
  7. data/Rakefile +1 -13
  8. data/app/assets/javascripts/media_magick/plupload_it.js +54 -45
  9. data/app/controllers/media_magick/attach_controller.rb +6 -6
  10. data/app/helpers/media_magick/application_helper.rb +58 -48
  11. data/app/views/_loader.html.erb +14 -0
  12. data/app/views/_uploader.html.erb +13 -0
  13. data/app/views/_video_uploader.html.erb +2 -0
  14. data/config/locales/en.yml +1 -0
  15. data/gemfiles/mongoid-3.0.gemfile +1 -2
  16. data/lib/media_magick.rb +1 -1
  17. data/lib/media_magick/controller/helpers.rb +25 -5
  18. data/lib/media_magick/engine.rb +1 -1
  19. data/lib/media_magick/image/dimensions.rb +23 -0
  20. data/lib/media_magick/model.rb +22 -5
  21. data/lib/media_magick/version.rb +2 -2
  22. data/media_magick.gemspec +10 -13
  23. data/spec/controllers/media_magick/attach_controller_spec.rb +35 -21
  24. data/spec/dummy/app/assets/javascripts/store/products.js +2 -0
  25. data/spec/dummy/app/assets/stylesheets/store/products.css +4 -0
  26. data/spec/dummy/app/controllers/store/products_controller.rb +83 -0
  27. data/spec/dummy/app/helpers/store/products_helper.rb +2 -0
  28. data/spec/dummy/app/models/post.rb +1 -0
  29. data/spec/dummy/app/models/store/product.rb +10 -0
  30. data/spec/dummy/app/models/user.rb +3 -2
  31. data/spec/dummy/app/uploaders/post_uploader.rb +11 -3
  32. data/spec/dummy/app/views/posts/_form.html.erb +16 -5
  33. data/spec/dummy/app/views/posts/index.html.erb +1 -1
  34. data/spec/dummy/app/views/store/products/_form.html.erb +34 -0
  35. data/spec/dummy/app/views/store/products/edit.html.erb +6 -0
  36. data/spec/dummy/app/views/store/products/index.html.erb +21 -0
  37. data/spec/dummy/app/views/store/products/new.html.erb +5 -0
  38. data/spec/dummy/app/views/store/products/show.html.erb +5 -0
  39. data/spec/dummy/config/boot.rb +1 -1
  40. data/spec/dummy/config/environments/development.rb +2 -1
  41. data/spec/dummy/config/routes.rb +5 -0
  42. data/spec/fixtures/example.jpg +0 -0
  43. data/spec/helpers/media_magick/application_helper_spec.rb +86 -33
  44. data/spec/lib/media_magick/controller/helper_spec.rb +40 -15
  45. data/spec/lib/media_magick/image/dimensions_spec.rb +62 -0
  46. data/spec/lib/media_magick/model_spec.rb +9 -3
  47. data/spec/views/_upload.html.erb_spec.rb +3 -3
  48. data/tmp/rspec_guard_result +1 -0
  49. metadata +52 -48
  50. data/app/views/_file.html.erb +0 -6
  51. data/app/views/_image.html.erb +0 -6
  52. data/app/views/_upload.html.erb +0 -12
  53. data/app/views/_video.html.erb +0 -8
data/.gitignore CHANGED
@@ -7,4 +7,5 @@ spec/dummy/public/uploads
7
7
  spec/dummy/.sass-cache
8
8
  uploads
9
9
  .DS_Store
10
- .rvmrc
10
+ .rvmrc
11
+ *.gem
data/CHANGELOG.md CHANGED
@@ -1,4 +1,56 @@
1
- ## Next Release (branch: master)
1
+ ## Next Release (branch: v0.4)
2
+
3
+ * support rails 4
4
+
5
+ ## 0.3.0 - July 1, 2013
6
+
7
+ ### Helpers
8
+
9
+ * `attachment_container` and `attachment_container_for_video` are deprecated. please use `attachment_uploader` (for upload) and `attachment_loader` for rendering resources
10
+
11
+ * new option for custom partial render after upload `attachment_uploader(model, relation, type, {loader_partial: 'path/to/custom_loader'})`
12
+
13
+ ### Libraries
14
+
15
+ * carrierwave ~> 0.8
16
+
17
+ * mongoid >= 3.0
18
+
19
+ * mini_magick ~> 3.5 (now is a gem dependency)
20
+
21
+ * updates jquery - 1.9.1
22
+
23
+ ### Bugs found
24
+
25
+ * attaches_many :videos - 'videos' is a reserved word
26
+
27
+ * attachments for models inside a module [fixed]
28
+
29
+
30
+ ## branch v0.3 untill 12.2012
31
+
32
+ Helpers:
33
+
34
+ * `attachment_container_for_video` doesn't render resources (images or videos)
35
+
36
+ * updates carrierwave (~> 0.7.0)
37
+
38
+ * store image dimensions in mongodb to avoid unnecessary file reads (when call method size - lazy behaviour)
39
+
40
+ ### Resolved Issues
41
+
42
+ * #2 - video upload for attaches one relation
43
+
44
+
45
+ ## 0.1.1 - October 11, 2012
46
+
47
+ ## 0.2.0 - November 19, 2012
48
+
49
+ ### Improvements
50
+
51
+ * Update carrierwave to 0.7.0.
52
+
53
+ ## 0.1.1 - October 11, 2012
2
54
 
3
55
  ## 0.2.0 - November 19, 2012
4
56
 
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in media_magick.gemspec
4
3
  gemspec
5
4
 
6
- # jquery-rails is used by the dummy application
7
5
  gem 'jquery-rails'
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/LICENSE CHANGED
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # MediaMagick [![Build Status](https://secure.travis-ci.org/nudesign/media_magick.png?branch=master)](http://travis-ci.org/nudesign/media_magick) [![Build Status](https://gemnasium.com/nudesign/media_magick.png)](http://gemnasium.com/nudesign/media_magick) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/nudesign/media_magick)
1
+ # MediaMagick [![Build Status](https://secure.travis-ci.org/nudesign/media_magick.png?branch=master)](http://travis-ci.org/nudesign/media_magick) [![Build Status](https://gemnasium.com/nudesign/media_magick.png)](http://gemnasium.com/nudesign/media_magick) [![Code Climate](https://codeclimate.com/github/nudesign/media_magick.png)](https://codeclimate.com/github/nudesign/media_magick)
2
2
 
3
3
  MediaMagick aims to make dealing with multimedia resources a very easy task – like magic. It wraps up robust solutions for upload, associate and display images, videos, audios and files to any model in your rails app.
4
4
 
@@ -6,7 +6,7 @@ MediaMagick aims to make dealing with multimedia resources a very easy task –
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'media_magick'
9
+ gem 'media_magick', '~> 0.3.0'
10
10
 
11
11
  And then execute:
12
12
 
@@ -14,6 +14,15 @@ And then execute:
14
14
 
15
15
  ## Getting Started
16
16
 
17
+ ### Assets
18
+
19
+ Add these lines after `//= require jquery` in `app/assets/javascripts/application.js`:
20
+
21
+ ```
22
+ //= require media_magick/plupload_it
23
+ //= require media_magick/toggleSortable
24
+ ```
25
+
17
26
  ### Model
18
27
 
19
28
  ``` ruby
@@ -21,7 +30,7 @@ class Album
21
30
  include Mongoid::Document
22
31
  include MediaMagick::Model
23
32
 
24
- attachs_many :photos
33
+ attaches_many :photos, type: :image
25
34
  end
26
35
  ```
27
36
 
@@ -36,7 +45,8 @@ end
36
45
  ### View
37
46
 
38
47
  ``` erb
39
- <%= attachment_container @album, :files %>
48
+ <%= attachment_uploader(@album, :photos, :image) %>
49
+ <%= attachment_loader(@album, :photos) %>
40
50
  ```
41
51
 
42
52
  ### Javascript
@@ -47,6 +57,23 @@ $(document).ready(function () {
47
57
  });
48
58
  ```
49
59
 
60
+ ### Allow Videos (youtube/vimeo)
61
+
62
+ ``` ruby
63
+ class Album
64
+ include Mongoid::Document
65
+ include MediaMagick::Model
66
+
67
+ attaches_many :photos, type: :image, allow_videos: true
68
+ end
69
+ ```
70
+
71
+ ``` erb
72
+ <%= attachment_uploader(@album, :photos, :video) %>
73
+ <%= attachment_uploader(@album, :photos, :image) %>
74
+ <%= attachment_loader(@album, :photos) %>
75
+ ```
76
+
50
77
  ## Configuring
51
78
 
52
79
  ### Model
@@ -133,25 +160,8 @@ album.reload.photos.first.thumb.url
133
160
 
134
161
  ### Form View
135
162
 
136
- ``` erb
137
- <%= attachment_container @album, :files %>
138
-
139
- <%= attachment_container @album, :files, newAttachments: { class: 'thumbnails' }, loadedAttachments: { class: 'span3' } %>
140
- ```
141
-
142
- or use a custom layout:
163
+ coming soon
143
164
 
144
- ``` html
145
- <%= attachment_container @album, :photos do %>
146
-
147
- <a class="pickAttachments btn" href="javascript://">select files</a>
148
- <a class="uploadAttachments btn" href="javascript://">upload files</a>
149
-
150
- <ul class="loadedAttachments">
151
- <%= render :partial => 'photos', :collection => @album.photos, :as => 'photo' %>
152
- </ul>
153
- <% end %>
154
- ```
155
165
 
156
166
  ## Contributing
157
167
 
data/Rakefile CHANGED
@@ -1,18 +1,6 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
-
8
1
  require 'bundler/gem_tasks'
9
2
  require 'rspec/core/rake_task'
10
3
 
11
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
12
- load 'rails/tasks/engine.rake'
13
-
14
- Bundler::GemHelper.install_tasks
15
-
16
4
  RSpec::Core::RakeTask.new(:spec)
17
5
 
18
- task :default => 'spec'
6
+ task default: 'spec'
@@ -18,14 +18,14 @@
18
18
  (function($) {
19
19
 
20
20
  $.fn.pluploadIt = function (options) {
21
-
21
+
22
22
  var settings = $.extend({
23
23
  browse_button: 'pickAttachments', // triggers modal to select files
24
24
  container: 'attachmentUploader',
25
25
  drop_element: 'dropAttachments',
26
26
  flash_swf_url: '/assets/plupload.flash.swf',
27
27
  max_file_size: '10mb',
28
- queue_element: 'attachmentQueue',
28
+ queue_element: 'attachmentQueue',
29
29
  resize: false,
30
30
  runtimes: 'gears,html5,flash,browserplus,html4',
31
31
  silverlight_xap_url: '/assets/plupload.silverlight.xap',
@@ -39,14 +39,15 @@
39
39
 
40
40
  var $container = $(this);
41
41
  settings.container = $container.attr('id');
42
-
42
+ var modelAndRelation = $container.data('model').replace('::','-') + "-" + $container.data('relation');
43
+
43
44
  // setup unique ids from classes
44
45
  $container.find('.' + settings.browse_button).attr('id', settings.container + '-' + settings.browse_button);
45
46
  $container.find('.' + settings.drop_element).attr('id', settings.container + '-' + settings.drop_element);
46
47
  $container.find('.' + settings.queue_element).attr('id', settings.container + '-' + settings.queue_element);
47
48
  $container.find('.' + settings.target_list).attr('id', settings.container + '-' + settings.target_list);
48
49
  $container.find('.' + settings.upload_button).attr('id', settings.container + '-' + settings.upload_button);
49
-
50
+
50
51
  var uploader = new plupload.Uploader({
51
52
  browse_button: settings.container + '-' + settings.browse_button,
52
53
  container: settings.container,
@@ -58,6 +59,7 @@
58
59
  relation: $container.data('relation'),
59
60
  model: $container.data('model'),
60
61
  partial: $container.data('partial') === undefined ? '' : $container.data('partial'),
62
+ loader_partial: $container.data('loader-partial') === undefined ? '' : $container.data('loader-partial'),
61
63
  embedded_in_model: $container.data('embedded-in-model') === undefined ? '' : $container.data('embedded-in-model'),
62
64
  embedded_in_id: $container.data('embedded-in-id') === undefined ? '' : $container.data('embedded-in-id')
63
65
  },
@@ -70,45 +72,6 @@
70
72
 
71
73
  uploader.bind('Init', function(up, params) {
72
74
  if ($('#' + settings.container + '-runtimeInfo').length > 0) $('#' + settings.container + '-runtimeInfo').text("Current runtime: " + params.runtime);
73
- // if ($container.find("dt").length > 0 && $container.find("dt").text() == "") $container.find("dt").text($container.attr('id'));
74
-
75
- var modelAndRelation = $container.data('model') + "-" + $container.data('relation');
76
-
77
- $("#" + $container.attr("id") + " a.remove").live('click', function() {
78
- var $attachment = $(this).parents('.attachment');
79
- var $attachmentUploader = $(this).parents('.attachmentUploader');
80
-
81
- $.get('/remove', {
82
- model: $container.data('model'),
83
- id: $container.data('id'),
84
- relation: $container.data('relation'),
85
- relation_id: $attachment.data('id'),
86
- embedded_in_model: $attachmentUploader.data('embedded-in-model'),
87
- embedded_in_id: $attachmentUploader.data('embedded-in-id')
88
- }, function(data) {
89
- $attachment.remove();
90
- });
91
- });
92
-
93
- $("#attachmentVideoUploader" + modelAndRelation).live('click', function() {
94
- var $attachment = $(this).parents('.attachment');
95
- var $attachmentUploader = $(this).parents('.attachmentUploader');
96
- var $videoField = $("#attachmentVideoUploaderField" + modelAndRelation);
97
-
98
- $.get('/upload', {
99
- model: $container.data('model'),
100
- id: $container.data('id'),
101
- relation: $container.data('relation'),
102
- relation_id: $attachment.data('id'),
103
- embedded_in_model: $attachmentUploader.data('embedded-in-model'),
104
- embedded_in_id: $attachmentUploader.data('embedded-in-id'),
105
- partial: $container.data('partial') === undefined ? '' : $container.data('partial'),
106
- video: $videoField.val()
107
- }, function(data) {
108
- $("#" + $container.attr("id") + "-loadedAttachments").append(data);
109
- $videoField.val("");
110
- });
111
- });
112
75
  });
113
76
 
114
77
  $('#' + settings.container + '-' + settings.upload_button).click(function(e) {
@@ -152,11 +115,57 @@
152
115
  uploader.bind('FileUploaded', function(up, file, response) {
153
116
  $('#' + file.id).addClass('completed');
154
117
  $('#' + file.id + " span.status").html("100%");
155
- $("#" + container + '-' + target_list).append(response.response);
118
+ $("#" + modelAndRelation + '-' + target_list).append(response.response);
156
119
  });
157
120
  })(settings.container, settings.queue_element, settings.target_list);
158
121
 
159
122
  });
160
123
 
161
124
  };
162
- })(jQuery);
125
+ })(jQuery);
126
+
127
+ $(function() {
128
+ // video upload (youtube/vimeo)
129
+ $('.attachmentVideoUploader').on('click', 'a.attachmentVideoUploaderButton', function(){
130
+ var $container = $(this).parent(".attachmentVideoUploader");
131
+ var $attachment = $(this).parents('.attachment');
132
+ var $videoField = $container.find(".attachmentVideoUploaderField");
133
+ var modelAndRelation = $container.data('model').replace('::','-') + "-" + $container.data('relation');
134
+
135
+ $.get('/upload', {
136
+ model: $container.data('model'),
137
+ id: $container.data('id'),
138
+ relation: $container.data('relation'),
139
+ relation_id: $attachment.data('id'),
140
+ embedded_in_model: $container.data('embedded-in-model'),
141
+ embedded_in_id: $container.data('embedded-in-id'),
142
+ partial: $container.data('partial') === undefined ? '' : $container.data('partial'),
143
+ video: $videoField.val()
144
+ }, function(data) {
145
+ $('#' + modelAndRelation + '-loadedAttachments').append(data);
146
+ $videoField.val("");
147
+ });
148
+ });
149
+
150
+ // attachment removal
151
+ $('.loadedAttachments').on('click', 'a.remove', function() {
152
+ var confirmation_message = $(this).data("confirmation");
153
+ var answer = confirm(confirmation_message);
154
+
155
+ if(answer) {
156
+ var $container = $(this).parents('.loadedAttachments');
157
+ var $attachment = $(this).parents('.attachment');
158
+
159
+ $.get('/remove', {
160
+ model: $container.data('model'),
161
+ id: $container.data('id'),
162
+ relation: $container.data('relation'),
163
+ relation_id: $attachment.data('id'),
164
+ embedded_in_model: $container.data('embedded-in-model'),
165
+ embedded_in_id: $container.data('embedded-in-id')
166
+ }, function(data) {
167
+ $attachment.remove();
168
+ });
169
+ }
170
+ });
171
+ });
@@ -8,20 +8,20 @@ module MediaMagick
8
8
  def create
9
9
  if !params[:embedded_in_model].blank?
10
10
  embedded_in = params[:embedded_in_model].constantize.find(params[:embedded_in_id])
11
- klass = embedded_in.send(params[:model].pluralize.downcase).find(params[:id])
11
+ obj = embedded_in.send(params[:model].pluralize.downcase).find(params[:id])
12
12
  else
13
- klass = params[:model].constantize.find(params[:id])
13
+ obj = params[:model].constantize.find(params[:id])
14
14
  end
15
15
 
16
16
  if params[:video]
17
- attachment = klass.send(params[:relation].pluralize).create(video: params[:video])
17
+ attachment = create_video(obj, params)
18
18
  else
19
- attachment = klass.send(params[:relation].pluralize).create(params[:relation].singularize => params[:file])
19
+ attachment = obj.send(params[:relation]).create(params[:relation].singularize => params[:file])
20
20
  end
21
21
 
22
- klass.save
22
+ obj.save
23
23
 
24
- partial = params[:partial].blank? ? "/#{attachment.class::TYPE}" : params[:partial]
24
+ partial = params[:loader_partial].blank? ? "/loader" : params[:loader_partial]
25
25
 
26
26
  render :partial => partial, :locals => {:model => params[:model], :relation => params[:relation], :attachment => attachment}
27
27
  end
@@ -1,71 +1,81 @@
1
1
  module MediaMagick
2
2
  module ApplicationHelper
3
- def attachment_container(model, relation, options = {})
4
- data_attributes = {
5
- model: model.class.to_s,
6
- id: model.id.to_s,
7
- relation: relation.to_s
8
- }
3
+ def attachment_uploader(model, relation, type, options={})
4
+ id = "#{model_name_for_id(model)}-#{relation.to_s}-#{type.to_s}"
5
+ classes = "attachmentUploader"
6
+ partial = get_partial("/uploader", options)
7
+ data = data_attributes(model, relation, partial, options)
9
8
 
10
- data_attributes.merge!(:partial => get_partial_name(options))
11
- data_attributes.merge!(:embedded_in_id => options[:embedded_in].id.to_s, :embedded_in_model => options[:embedded_in].class.to_s) if options[:embedded_in]
9
+ if type == :video
10
+ partial = "/video_uploader"
11
+ classes = "attachmentVideoUploader"
12
+ end
12
13
 
13
- content_tag :div, id: model.class.to_s.downcase << '-' << relation.to_s, class: 'attachmentUploader ' << relation.to_s, data: data_attributes do
14
+ content_tag :div, id: id, class: classes, data: data do
14
15
  if block_given?
15
16
  yield
16
17
  else
17
- partial_attributes = {
18
- model: model,
19
- relations: relation,
20
- newAttachments: options[:newAttachments] || {},
21
- loadedAttachments: options[:loadedAttachments] || {},
22
- partial: get_partial_name(options)
23
- }
24
-
25
- render '/upload', partial_attributes
18
+ render partial
26
19
  end
27
20
  end
28
21
  end
29
22
 
30
- def attachment_container_for_video(model, relation, options = {})
31
- data_attributes = {
32
- model: model.class.to_s,
33
- id: model.id.to_s,
34
- relation: relation.to_s
35
- }
23
+ def attachment_loader(model, relation, options={})
24
+ id = "#{model_name_for_id(model)}-#{relation.to_s}-loadedAttachments"
25
+ classes = "#{relation.to_s} loadedAttachments"
26
+ partial = get_partial("/loader", options)
27
+ data = data_attributes(model, relation, partial, options)
36
28
 
37
- data_attributes.merge!(:partial => get_partial_name(options))
38
- data_attributes.merge!(:embedded_in_id => options[:embedded_in].id.to_s, :embedded_in_model => options[:embedded_in].class.to_s) if options[:embedded_in]
39
-
40
- content_tag :div, id: model.class.to_s.downcase << '-' << relation.to_s, class: 'attachmentUploader ' << relation.to_s, data: data_attributes do
29
+ content_tag :div, id: id, class: classes, data: data do
41
30
  if block_given?
42
31
  yield
43
32
  else
44
- partial_attributes = {
45
- model: model,
46
- relations: relation,
47
- newAttachments: options[:newAttachments] || {},
48
- loadedAttachments: options[:loadedAttachments] || {},
49
- partial: get_partial_name(options)
50
- }
51
-
52
- render '/video', partial_attributes
33
+ render partial: partial,
34
+ collection: model.send(relation),
35
+ as: :attachment,
36
+ locals: { model: nil, relation: nil }
53
37
  end
54
38
  end
55
39
  end
56
40
 
41
+ def attachment_container(model, relation, options = {})
42
+ warn "%" * 50
43
+ warn "[DEPRECATION] `attachment_container` is deprecated. please use `attachment_uploader`"
44
+ warn "%" * 50
45
+ end
46
+
47
+ def attachment_container_for_video
48
+ warn "%" * 50
49
+ warn "[DEPRECATION] `attachment_container_for_video` is deprecated. please use `attachment_uploader`"
50
+ warn "%" * 50
51
+ end
52
+
57
53
  private
54
+ def data_attributes(model, relation, partial, options)
55
+ data_attributes = {
56
+ model: model_name(model),
57
+ id: model.id.to_s,
58
+ relation: relation.to_s
59
+ }
58
60
 
59
- def get_partial_name(options)
60
- if options[:partial]
61
- options[:partial]
62
- else
63
- if options[:as]
64
- "/#{options[:as]}"
65
- else
66
- '/image'
67
- end
61
+ data_attributes.merge!(partial: partial)
62
+ data_attributes.merge!(loader_partial: options[:loader_partial]) if options[:loader_partial]
63
+ data_attributes.merge!(embedded_in_id: options[:embedded_in].id.to_s, embedded_in_model: options[:embedded_in].class.to_s) if options[:embedded_in]
64
+
65
+ data_attributes
66
+ end
67
+
68
+ def get_partial(default, options)
69
+ return options[:partial] if options[:partial]
70
+ default
71
+ end
72
+
73
+ def model_name(model)
74
+ @model_name ||= model.class.to_s
75
+ end
76
+
77
+ def model_name_for_id(model)
78
+ model_name(model).gsub(/::/, '-')
68
79
  end
69
- end
70
80
  end
71
- end
81
+ end