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

undefined method `save_as' for #<Mechanize::Image:0x000000057e6580> #246

Closed
phlegx opened this issue Jul 23, 2012 · 5 comments
Closed

undefined method `save_as' for #<Mechanize::Image:0x000000057e6580> #246

phlegx opened this issue Jul 23, 2012 · 5 comments
Assignees

Comments

@phlegx
Copy link

phlegx commented Jul 23, 2012

Switching over from version 2.1.1 to 2.5.1 I do get the following error:

undefined method save_as' for #Mechanize::Image:0x000000057e6580`

The code would be:

...
agent.get(image_url).save_as folder
...

Any ideas what might be wrong here?

@aboutaaron
Copy link

Ran into the same issue today myself. I'm calling save_as in a loop but didn't run into this issue earlier today when scraping for .xls files on another page.

@aboutaaron
Copy link

@phlegx oddly enough, the save method works just fine for me.

@phlegx
Copy link
Author

phlegx commented Jul 25, 2012

@aboutaaron For me the "save" method works too. Thank you for the hint!

Looks like "save_as" method simply has been removed. Unfortunately nothing was mentioned in the CHANGELOG...

@ghost ghost assigned drbrain Aug 14, 2012
@leejarvis
Copy link
Member

It looks like Mechanize::Image which inherits from Mechanize::Download never had a save_as method. File and FileSaver have these methods, perhaps that was confusing?

[2] pry(main)> Mechanize::VERSION
=> "2.1.1"
[6] pry(main)> Mechanize::Image.new.save_as
NoMethodError: undefined method `save_as' for #<Mechanize::Image:0x007fac2da9f890>

@drbrain
Copy link
Member

drbrain commented Feb 1, 2013

Previously a resource with an image/* MIME type was returned as a Mechanize::File, so this is partially true.

Since #save_as worked in Mechanize 2.0 we should add #save_as to Mechanize::Download

leejarvis added a commit that referenced this issue Feb 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants