Notes posted by dennismonsewiczRSS feed
When needing to include a helper method inside of a controller, instead of including the ENTIRE helper module, simply use this method like so:
module ApplicationHelper def fancy_helper(str) str.titleize end end class MyController < ApplicationController def index @title = view_context.fancy_helper "dogs are awesome" end end
Over the weekend I kept running into instances where I was writing code like this:
arr = ['hello', 'world'] if arr.length > 2 # do stuff else # do something else end
So I ended up extending the core and adding an instance method of more_than?
arr = ['hello', 'world'] puts "Hello" if arr.more_than? 1