Search code examples
rubytwitter

Can't save user profiler image


I'm working on Ruby script with Twitter API. I try to save profile image fetched but couldn't.

@image = subject.user.profile_image_url
=> #<Addressable::URI:xxxxxxxx URI:http://pbs.twimg.com/profile_images/xxxxxxxxxx/m_xxxxxxxxxxx.jpg>

I want to save only image URI. It's not concise. How can I remove #<Addressable::URI:xxxxxxxx >?


Solution

  • You have to use path method:

    @image = subject.user.profile_image_url.path
    

    Check more in documenation