Skip to content

Instantly share code, notes, and snippets.

@sighmin
Created September 29, 2015 19:50
Show Gist options
  • Save sighmin/665903bed43d405fc78e to your computer and use it in GitHub Desktop.
Save sighmin/665903bed43d405fc78e to your computer and use it in GitHub Desktop.
module ViewHelpers
def urls
Rails.application.routes.url_helpers
end
def helpers
ActionController::Base.helpers
end
end
class UserView < SimpleDelegator
include ViewHelpers
def initialize(delegate, salutation: 'Padawan')
super(delegate)
@salutation = salutation
end
def fullname
"#{salutation} #{first_name} #{last_name}"
end
def master_users_path
helpers.link_to "MAASTERS", urls.users_path(skill: 'master')
end
private
attr_reader :salutation
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment