Created
October 31, 2012 01:05
-
-
Save Veejay/3984189 to your computer and use it in GitHub Desktop.
Decorator method
This file contains 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
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