Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: undefined method 'chomp' #31

Open
ekan opened this issue Mar 25, 2014 · 1 comment
Open

NoMethodError: undefined method 'chomp' #31

ekan opened this issue Mar 25, 2014 · 1 comment

Comments

@ekan
Copy link

ekan commented Mar 25, 2014

Just bundle updated to the latest gem (0.8.1), now I can't post to Tumblr. Here's my code to post:

      Tumblr.configure do |config|
        config.consumer_key = ENV['TUMBLR_API_KEY']
        config.consumer_secret = ENV['TUMBLR_SECRET']
        config.oauth_token = poster.network.tumblr_key
        config.oauth_token_secret = poster.network.tumblr_secret
      end
      file = open(URI.parse(ENV['SERVER_DOMAIN_WITH_PORT'] + poster.social_attachment_url))
      client = Tumblr::Client.new
      response = client.photo "#{poster.network.tumblr_hostname}.tumblr.com", 
        :data => [file],
        :caption => poster.txt_content,
        :link => "http://www.theredpost.com/posters/#{poster.id}",
        :tags => "redpost,#{poster.network.tumblr_hostname}"

And I'm getting this error, from the mime-type gem:

NoMethodError: undefined method `chomp' for #<Tempfile:0x007fd0ded27538>
    from /Users/ekan/redpost_git/RedPost/thin/ruby/1.9.1/gems/mime-types-1.25.1/lib/mime/types.rb:672:in `type_for'
    from /Users/ekan/redpost_git/RedPost/thin/ruby/1.9.1/gems/mime-types-1.25.1/lib/mime/types.rb:874:in `type_for'
    from /Users/ekan/redpost_git/RedPost/thin/ruby/1.9.1/gems/tumblr_client-0.8.1/lib/tumblr/post.rb:107:in `block in extract_data!'
    from /Users/ekan/redpost_git/RedPost/thin/ruby/1.9.1/gems/tumblr_client-0.8.1/lib/tumblr/post.rb:106:in `each'
    from /Users/ekan/redpost_git/RedPost/thin/ruby/1.9.1/gems/tumblr_client-0.8.1/lib/tumblr/post.rb:106:in `with_index'
    from /Users/ekan/redpost_git/RedPost/thin/ruby/1.9.1/gems/tumblr_client-0.8.1/lib/tumblr/post.rb:106:in `extract_data!'
    from /Users/ekan/redpost_git/RedPost/thin/ruby/1.9.1/gems/tumblr_client-0.8.1/lib/tumblr/post.rb:28:in `photo'
    from (irb):10
    from /Users/ekan/redpost_git/RedPost/thin/ruby/1.9.1/gems/railties-3.2.17/lib/rails/commands/console.rb:47:in `start'
    from /Users/ekan/redpost_git/RedPost/thin/ruby/1.9.1/gems/railties-3.2.17/lib/rails/commands/console.rb:8:in `start'
    from /Users/ekan/redpost_git/RedPost/thin/ruby/1.9.1/gems/railties-3.2.17/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Here's the code from the gem:

672      ext = filename.chomp.downcase.gsub(/.*\./o, '')
673      list = @extension_index[ext]
674      list.delete_if { |e| not e.platform? } if platform

Any ideas?

@indirect
Copy link

The downloaded file was too big to be stored directly in a string, so it was stuffed into a Tempfile. That's just how the open() call works in ruby. The Tempfile is an IO object, not a string with a path to the location. You'll need to get the filename out of the Tempfile and pass it to the tumblr_client method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants