24 April 2014

The Ruby Reflector

Topic

NoMethodError

  Source Favicon
Email

If the user isn't logged in, this will fail with NoMethodError: undefined method 'last_in_category' for []:Array .

Rails to the Rescue!

Luckily, Rails 4.0 introduced a new method on ActiveRecord::Relation to help with exactly this situation! Relation#none is a method that will return a new instance of NullRelation .

NullRelation responds to every method that a normal instance of Relation would. As a bonus, when you call .none on one of your model …

robots.thoughtbot.com Read
  Source Favicon
By Bryan McLellan of Chef Blog 1 year ago.
Email

[ CHEF-3809 ] - Getting error NoMethodError: undefined method ` CloseHandle' for Chef:: ReservedNames:: Win32::Handle:Class on Windows servers

[ CHEF-3836 ] - Run Lock tests randomly fail on slower Ci machines

Improvement

[ CHEF-3156 ] - Net:: SSH dependency prevents using HMAC SHA2 family

Release Notes - 10.20.0

Bug

[ CHEF-2960 ] - Upgrade JSON dependency to 1.7+

[ CHEF-3367 ] …

opscode.com Read
  Source Favicon
By Bryan McLellan of Chef Blog over 1 year ago.
Email

…statement: block in configure\_session': undefined method []' for nil: NilClass ( NoMethodError)

[ CHEF-3489 ] - chef-client should permit whitespace in -override-runlist

[ CHEF-3508 ] - Improper usage of Fileutils#rm_f in Chef::Provider:: Ifconfig

Improvement

[ CHEF-2826 ] - pacman (arch package provider) doesn't allow for custom package repos

[ CHEF-3455 ] - Add commandline options to allow …

opscode.com Read
  Source Favicon
By santiago.pastorino of WyeWorks Blog - The Team's Voice over 1 year ago.
Email

…puts [].blank? puts [1].blank? end

This will raise an undefined method `blank?' for ( NoMethodError).

Refinements has been committed to ruby by Shugo Maeda, but it may be reverted for Ruby 2.0. The Ruby Core is asking for feedback, so, what are the use cases you see Refinements is good for you?

You can learn more about Refinements reading Refinements in practice, a blog post from Yehuda Katz

blog.wyeworks.com Read
  Source Favicon
By David of David Chelimsky almost 2 years ago.
Email

Fix regression of edge case behavior. double.should_receive(:foo) { a } was causing a NoMethodError when double.stub(:foo).and_return(a, b) had been setup before ( Myron Marston).

Infinite loop generated by using any_instance and dup . ( Sidu Ponnappa @ kaiwren)

double.should_receive(:foo).at_least(:once).and_return(a) always returns a even if :foo is already stubbed.

Prevent infinite loop when interpolating a null double into a string as an integer ( "%i" % double.as null object…

blog.davidchelimsky.net Read
  Source Favicon
By Sarah of the evolving ultrasaurus over 2 years ago.
Email

undefined method `xml_subset_of?' for # ( NoMethodError)

As it turns out, in my zeal to make sure everything was using the latest and great new stuff, I had forgotten to move over this critical configuration line in cucumbers env.rb:

World(CustomMatchers)

Now, my cucumber feature is happily failing cuz my code doesn't work. Whew. I couldn't find this documented anywhere and I'm not even sure where this documentation would belong. I found a hint on the cucumber …

ultrasaurus.com Read
  Source Favicon
Email

…) handled the case where using the :id_partition pattern in a URL or path pattern raises a NoMethodError on an unsaved resource ( ac82244 ). He and I are now enemies for life for his use of nil .

Prem fixed another bug: if you have a path or URL pattern with :class in it it will show a warning. He removed this warning ( b4ff2c5 ).

Prem worked with Steve Richert ( laserlemon ) to show the Gemnasium results in the README ( 3e20907 and …

robots.thoughtbot.com Read
  Source Favicon
By David of David Chelimsky over 2 years ago.
Email

allow to_ary to be called without raising NoMethodError ( Mikhail Dieterle)

any_instance properly restores private methods ( Sidu Ponnappa)

rspec-rails-2.7.0

full changelog

Enhancments

ActiveRecord::Relation can use the =~ matcher ( Andy Lindeman)

Make generated controller spec more consistent with regard to ids ( Brent J. Nordquist)

Less restrictive autotest mapping between spec and implementation files ( José Valim)

require 'rspec/autorun' …

blog.davidchelimsky.net Read
  Source Favicon
By Taryn of Ruby-coloured glasses over 2 years ago.
Email

Ack! I just tried to upgrade rubygems... and it destroyed my working version of rails 2.3.5 (yes, we use it for a client that has not yet upgraded due to the quite reasonable "it ain't broke" assumption).

Now I can't run script/server without one of the following errors: /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:268:in `==': undefined method `name' for " Ascii85": String ( NoMethodError) or /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:in …

rubyglasses.blogspot.com Read
  Source Favicon
By Aaron Patterson of Tender Lovemaking almost 3 years ago.
Email

Naturally, if we were to call to_ary directly on this object it would raise a NoMethodError exception. When calling flatten, ruby will swallow the exception. If we enable $DEBUG by running ruby with -d , we can see the exception: [aaron@higgins ~]$ ruby -d test.rb Exception `LoadError' at /Users/aaron/.local/lib/ruby/site_ruby/1.9.1/rubygems.rb:1215 - cannot load such file -- rubygems/defaults/operating_system Exception `LoadError' at /Users/aaron/.local/lib/ruby/site_ruby/1.9.1/rubygems.rb:1224 …

tenderlovemaking.com Read