Closed jonathansimmons closed 12 years ago
Can you post the stack trace from this error?
Here is the full trace. I hope this helps!
NoMethodError in Home#index
Showing /Users/jono/Documents/gitHub/WantKeeper/app/views/home/index.html.erb where line #43 raised:
undefined method `gsub' for nil:NilClass
Extracted source (around line #43):
40: <% image_scraper = ImageScraper::Client.new("http://www.amazon.com/OtterBox-Universal-Defender-Silicone-Plastic/dp/B004N7EY5S",:include_css_images=>false,:include_css_data_images=>false,:convert_to_absolute_url=>true) %>
41:
42:
43: <% image_scraper.image_urls.each do |i| %>
44:
45: <%= image_tag(i) %>
46: <% end %>
Rails.root: /Users/jono/Documents/gitHub/WantKeeper
Application Trace | Framework Trace | Full Trace
activesupport (3.1.3) lib/active_support/whiny_nil.rb:48:in `method_missing'
/opt/local/lib/ruby1.9/1.9.1/uri/common.rb:304:in `escape'
/opt/local/lib/ruby1.9/1.9.1/uri/common.rb:623:in `escape'
image_scraper (0.1.5) lib/image_scraper/client.rb:25:in `block in page_images'
nokogiri (1.5.0) lib/nokogiri/xml/node_set.rb:239:in `block in each'
nokogiri (1.5.0) lib/nokogiri/xml/node_set.rb:238:in `upto'
nokogiri (1.5.0) lib/nokogiri/xml/node_set.rb:238:in `each'
image_scraper (0.1.5) lib/image_scraper/client.rb:24:in `page_images'
image_scraper (0.1.5) lib/image_scraper/client.rb:16:in `image_urls'
app/views/home/index.html.erb:43:in `_app_views_home_index_html_erb___2941359318916507671_70106265131500'
actionpack (3.1.3) lib/action_view/template.rb:171:in `block in render'
activesupport (3.1.3) lib/active_support/notifications.rb:55:in `instrument'
actionpack (3.1.3) lib/action_view/template.rb:169:in `render'
actionpack (3.1.3) lib/action_view/renderer/template_renderer.rb:40:in `block (2 levels) in render_template'
actionpack (3.1.3) lib/action_view/renderer/abstract_renderer.rb:33:in `block in instrument'
activesupport (3.1.3) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.3) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.3) lib/action_view/renderer/abstract_renderer.rb:33:in `instrument'
actionpack (3.1.3) lib/action_view/renderer/template_renderer.rb:39:in `block in render_template'
actionpack (3.1.3) lib/action_view/renderer/template_renderer.rb:47:in `render_with_layout'
actionpack (3.1.3) lib/action_view/renderer/template_renderer.rb:38:in `render_template'
actionpack (3.1.3) lib/action_view/renderer/template_renderer.rb:12:in `block in render'
actionpack (3.1.3) lib/action_view/renderer/abstract_renderer.rb:22:in `wrap_formats'
actionpack (3.1.3) lib/action_view/renderer/template_renderer.rb:9:in `render'
actionpack (3.1.3) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.1.3) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.1.3) lib/abstract_controller/rendering.rb:120:in `_render_template'
actionpack (3.1.3) lib/action_controller/metal/streaming.rb:250:in `_render_template'
actionpack (3.1.3) lib/abstract_controller/rendering.rb:114:in `render_to_body'
actionpack (3.1.3) lib/action_controller/metal/renderers.rb:30:in `render_to_body'
actionpack (3.1.3) lib/action_controller/metal/compatibility.rb:43:in `render_to_body'
actionpack (3.1.3) lib/abstract_controller/rendering.rb:99:in `render'
actionpack (3.1.3) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.1.3) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/opt/local/lib/ruby1.9/1.9.1/benchmark.rb:295:in `realtime'
activesupport (3.1.3) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
activerecord (3.1.3) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.1.3) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.1.3) lib/action_controller/metal/mime_responds.rb:268:in `block in retrieve_response_from_mimes'
actionpack (3.1.3) lib/action_controller/metal/mime_responds.rb:195:in `call'
actionpack (3.1.3) lib/action_controller/metal/mime_responds.rb:195:in `respond_to'
app/controllers/home_controller.rb:27:in `index'
actionpack (3.1.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.1.3) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.1.3) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.1.3) lib/active_support/callbacks.rb:425:in `_run__1622411349193832906__process_action__2052148207590202028__callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.3) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.1.3) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.3) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
activerecord (3.1.3) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.1.3) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.1.3) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.1.3) lib/action_controller/metal.rb:193:in `dispatch'
actionpack (3.1.3) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.1.3) lib/action_controller/metal.rb:236:in `block in action'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:65:in `call'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:29:in `call'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in `block in call'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:in `block in recognize'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:75:in `optimized_each'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:532:in `call'
warden (1.0.5) lib/warden/manager.rb:35:in `block in call'
warden (1.0.5) lib/warden/manager.rb:34:in `catch'
warden (1.0.5) lib/warden/manager.rb:34:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.5) lib/rack/etag.rb:23:in `call'
rack (1.3.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/flash.rb:247:in `call'
rack (1.3.5) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.5) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/cookies.rb:331:in `call'
activerecord (3.1.3) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.3) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.5) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.3) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.5) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.5) lib/rack/lock.rb:15:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.3) lib/rails/engine.rb:456:in `call'
rack (1.3.5) lib/rack/content_length.rb:14:in `call'
railties (3.1.3) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.5) lib/rack/handler/webrick.rb:59:in `service'
/opt/local/lib/ruby1.9/1.9.1/webrick/httpserver.rb:138:in `service'
/opt/local/lib/ruby1.9/1.9.1/webrick/httpserver.rb:94:in `run'
/opt/local/lib/ruby1.9/1.9.1/webrick/server.rb:191:in `block in start_thread'
Request
Parameters:
None
Show session dump
Show env dump
Response
Headers:
None
anything?
sorry for the delay. It looks like the web page had an image without a "src" attribute. I just pushed a new version. Can you update your gem and see if you still get the error?
$ bundle update image_scraper
Thanks for making us aware of this problem!
Awesome!!! looks like that did the trick! Thanks again. I love this gem I will be sure to let you know if I find anything else and send you a link to the finished product of the app using it.
Glad that worked! Definitely let me know if you find any other problems
I'm a bit new to rails. I was excited to find your scraper as I believe it will do exactly what I want it to. However I keep getting this nil error when scraping any amazon.com url.
example "http://www.amazon.com/OtterBox-Universal-Defender-Silicone-Plastic/dp/B004N7EY5S"
It would appear to be that the strip_quotes function is the only thing using gsub and it's having issues when it's provided an empty url.
My thought was that I could just define :include_css_images=>false as that function only seems to be called when handling stylesheet urls but that did not fix the issue.
Again I'm new to rails so I wish I could give more info that may help. If I'm just clueless and missing something obvious then I do apologize. My hope is only to help make this gem better.