Skip to content

Instantly share code, notes, and snippets.

View sharipov-ru's full-sized avatar

Sharipov Ruslan sharipov-ru

View GitHub Profile
@krisleech
krisleech / 00-helper.rb
Created January 17, 2014 18:13
view conditional with yield
class MyPresenter
def initialize(user)
@user = user
end
def admin_only(&block)
yield if user.admin?
end
end
def back_or_home_path
referrer = controller.respond_to?(:request) && controller.request.env['HTTP_REFERER']
local_referrer = referrer && URI.parse(referrer).host == controller.request.host
if referrer && local_referrer
referrer
else
root_path
end
end
@sharipov-ru
sharipov-ru / development.rb
Last active December 20, 2016 14:20 — forked from dhh/gist:2492118
config.middleware.use RoutesReloader