Last active
December 19, 2017 11:39
-
-
Save henrik/6bb7d8cb06dd89c48b00 to your computer and use it in GitHub Desktop.
Convenient `locals` renderer for Rails. Don't use ivars if you can help it. http://thepugautomatic.com/2013/05/locals/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
# stuff | |
private | |
# These groups are equivalent: | |
# | |
# render action: :new, locals: { item: x } | |
# render :new, locals: { item: x } | |
# locals :new, item: x | |
# | |
# render locals: { item: x } | |
# locals item: x | |
# | |
def locals(action = nil, hash) | |
render action: action, locals: hash | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment