Skip to content

Instantly share code, notes, and snippets.

@kmiscia
Created September 7, 2012 14:42
Show Gist options
  • Save kmiscia/3666768 to your computer and use it in GitHub Desktop.
Save kmiscia/3666768 to your computer and use it in GitHub Desktop.
# The args to use for a radio button set of roles.
# Can be the args for a specific user, or a more
# generic non-model form.
def role_tag_args(role, user = nil)
if user
role_class = "user_role_#{role.name.downcase.gsub(" ", "_")}"
["user[role_ids][]", role.id, role_selected?(user, role), {:id => role_to_id(role), :class => role_class}]
else
['role_ids[]', role.id, (role.name == 'Contributor'), :style => 'margin-bottom: 2px;']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment