Skip to content

Commit

Permalink
avoid nil errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nragaz committed Jun 16, 2010
1 parent eef59f5 commit 13858b5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ gem "sqlite3-ruby", :require => 'sqlite3'
gem "activerecord", :git => "git://github.com/rails/rails", :require => "active_record"
gem "activeresource", :git => "git://github.com/rails/rails", :require => "active_resource"
gem "activesupport", :git => "git://github.com/rails/rails", :require => "active_support"
gem "paperclip", :git => "git://github.com/thoughtbot/paperclip", :branch => "rails3"
gem "paperclip"
3 changes: 2 additions & 1 deletion lib/activeresource/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ def has_encoded_attachment(name)
changed = (changed.nil? || changed) ? true : false
if file_url
url = URI.parse(file_url.to_s)
send "#{name}_content_type=", MIME::Types.type_for(File.basename(url.path)).first.content_type
send "#{name}=", StringIO.new(connection.get_attachment(url.path,
'Accept' => send("#{name}_content_type")).body), changed
'Accept' => send("#{name}_content_type"))), changed
send "#{name}_file_name=", File.basename(url.path)
send "#{name}_content_type=", MIME::Types.type_for(File.basename(url.path)).first.content_type
else
Expand Down
3 changes: 1 addition & 2 deletions lib/activeresource/connection.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module EncodedAttachment
module ActiveResourceConnectionMethods
def get_attachment(path, headers = {})
request_headers = build_request_headers(headers, :get, self.site.merge(path))
with_auth { request(:get, path, request_headers) }
with_auth { request(:get, path, build_request_headers(headers, :get, self.site.merge(path))).body }
end
end
end

0 comments on commit 13858b5

Please sign in to comment.