attachable 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,8 +46,17 @@ module Attachable
46
46
  tempfile.rewind #This may not be super efficient, but it's the necessary fix for Rails 3.1
47
47
  self["#{attachment_file_prefix}_data"] = tempfile.read
48
48
  self["#{attachment_file_prefix}_size"] = tempfile.size
49
- self["#{attachment_file_prefix}_name"] = tempfile.original_filename
50
- self["#{attachment_file_prefix}_type"] = tempfile.content_type
49
+
50
+ filename = nil
51
+ print "hi"
52
+ if tempfile.respond_to?(:original_filename)
53
+ filename = tempfile.original_filename
54
+ elsif tempfile.respond_to?(:path)
55
+ filename = File.basename(tempfile.path)
56
+ end
57
+ self["#{attachment_file_prefix}_name"] = filename unless filename.nil?
58
+
59
+ self["#{attachment_file_prefix}_type"] = tempfile.content_type if tempfile.respond_to?(:content_type)
51
60
  end
52
61
  end
53
62
 
@@ -1,3 +1,3 @@
1
1
  module Attachable
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attachable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-22 00:00:00.000000000 -08:00
12
+ date: 2012-05-02 00:00:00.000000000 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: Add methods to automatically manage a file as part of a Rails model