Today I Learned

hashrocket A Hashrocket project

Call super class method from different method

Bit verbose, but:

self.class.superclass.instance_method(:method_name).bind(self).call

For those times when you want to use super but you're calling from outside of the actual method on super.

I don't hate how explicit it is though. It can also be extracted into a helper class to eliminate some of the craziness.

See More #ruby TILs
Looking for help? Each developer at Hashrocket has years of experience working with Ruby applications of all types and sizes. We're an active presence at Ruby conferences, have written some of the most popular gems, and have worked on many of the web's Ruby on Rails success stories. Contact us today to talk about your Ruby project.