Patch #16710
closedSupport for the 1.x versions of mime-types gem
0%
Description
Even though Redmine doesn't specify in its Gemfile a minimum version for the mime-types gem, it still assumes that version is 2.x or later. This is because it uses MIME::Types.find.
Unfortunately, upgrading to mime-types 2.x would break the dependencies of the mail gem.
The attached patch uses MIME::Types.type_for which is present in both 1.x and 2.x versions of mime-types.
Tested with Redmine 2.5.1 + ruby 1.8.7 + rails 3.2.17
Files
Updated by Pierre-Louis Bonicoli over 11 years ago
MIME::Types.find has been added in mime-types here.
There is another error if this additional commit is not used.
Both commits are included in mime-types 1.23.
Particularly MIME::Types.find is used in lib/redmine/mime_type.rb since r12483.
- either with mime-types 1.23
- or with mime-types 1.19 when redmine-2.5.1-mime-types.patch is applied
First error fixed by 644259db36c69884735aa66aa6fdee690dfa9f7b:
ActionView::Template::Error (undefined method `find' for MIME::Types:Class):
1: <div class="attachments">
2: <% for attachment in attachments %>
3: <p><%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
4: <% if attachment.is_text? %>
5: <%= link_to image_tag('magnifier.png'),
6: :controller => 'attachments', :action => 'show',
lib/redmine/mime_type.rb:63:in `block in of'
lib/redmine/mime_type.rb:66:in `yield'
lib/redmine/mime_type.rb:66:in `default'
lib/redmine/mime_type.rb:66:in `of'
lib/redmine/mime_type.rb:78:in `main_mimetype_of'
lib/redmine/mime_type.rb:85:in `is_type?'
app/models/attachment.rb:217:in `is_text?'
app/views/attachments/_links.html.erb:3:in `block in _app_views_attachments__links_html_erb___3782281663955472009_30361420'
app/views/attachments/_links.html.erb:2:in `_app_views_attachments__links_html_erb___3782281663955472009_30361420'
app/helpers/attachments_helper.rb:31:in `link_to_attachments'
app/views/documents/show.html.erb:19:in `_app_views_documents_show_html_erb___505910332762640252_28753000'
Second error fixed by fd53425e33046932cebcf0d3d8f92c3e35cd4472:
ActionView::Template::Error (undefined method `extensions' for #<Array:0x000000053ecdf8>):
1: <div class="attachments">
2: <% for attachment in attachments %>
3: <p><%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
4: <% if attachment.is_text? %>
5: <%= link_to image_tag('magnifier.png'),
6: :controller => 'attachments', :action => 'show',
lib/redmine/mime_type.rb:63:in `block (2 levels) in of'
lib/redmine/mime_type.rb:63:in `find'
lib/redmine/mime_type.rb:63:in `block in of'
lib/redmine/mime_type.rb:66:in `yield'
lib/redmine/mime_type.rb:66:in `default'
lib/redmine/mime_type.rb:66:in `of'
lib/redmine/mime_type.rb:78:in `main_mimetype_of'
lib/redmine/mime_type.rb:85:in `is_type?'
app/models/attachment.rb:217:in `is_text?'
app/views/attachments/_links.html.erb:3:in `block in _app_views_attachments__links_html_erb__4198667861296620514_35003500'
app/views/attachments/_links.html.erb:2:in `_app_views_attachments__links_html_erb__4198667861296620514_35003500'
app/helpers/attachments_helper.rb:31:in `link_to_attachments'
app/views/documents/show.html.erb:19:in `_app_views_documents_show_html_erb__1410191189284416881_31521860'
Updated by Etienne Massip over 11 years ago
- Target version set to Candidate for next minor release
Updated by Jean-Philippe Lang over 11 years ago
- Status changed from New to Resolved
- Assignee set to Jean-Philippe Lang
- Target version changed from Candidate for next minor release to 2.5.2
Patch committed in r13107, thanks.