Today I Learned

hashrocket A Hashrocket project

Inline your helper_method declaration

Remember, def is just a special function in ruby and as such it has a return value that is a symbol that is the name of the function being defined.

That allows us to do some cool (weird?) looking things with class methods that take a symbol that refers to a function, like the helper_method call in a controller.

  class DataController < BaseController
  
  #actions and whatever

  private

  helper_method def format_that_data(data)
    "#{data[0]} X #{data[1]}"
  end

  end
See More #rails TILs
Looking for help? Hashrocket has been an industry leader in Ruby on Rails since 2008. Rails is a core skill for each developer at Hashrocket, and we'd love to take a look at your project. Contact us and find out how we can help you.