Skip to content

Instantly share code, notes, and snippets.

@AJFaraday
Created December 19, 2012 10:30
Show Gist options
  • Save AJFaraday/4335806 to your computer and use it in GitHub Desktop.
Save AJFaraday/4335806 to your computer and use it in GitHub Desktop.
insanity?
# attempt to use underscored attributes
# e.g. labware_item_id would still return labwareitemid
def method_missing(method, *args, &block)
super method, args, block
rescue
if method.to_s.include?('_')
m = method.to_s
m = m.gsub('_', '').downcase
puts "#{method} is not present, trying #{m}"
return self.send m
else
raise NoMethodError
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment