Skip to content

Instantly share code, notes, and snippets.

@Veejay
Created October 31, 2012 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Veejay/3984189 to your computer and use it in GitHub Desktop.
Save Veejay/3984189 to your computer and use it in GitHub Desktop.
Decorator method
def permissions_information_for_company(company)
init_haml_helpers
m = user.memberships.where(company_id: company.id).first
capture_haml do
haml_tag :div, {:class => "permissions_info"} do
haml_tag :h2 do
haml_concat "Permissions"
end
if m.permissions.present?
haml_concat "#{user.full_name} has the following permissions for company #{company.name}:"
haml_tag :ul do
m.permissions.each do |perm|
haml_tag :li do
haml_concat perm.to_s
end
end
end
else
haml_concat "#{user.full_name} currently doesn't have any permissions for company #{company.name}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment