Is there an easy way to humanize string in collection_select?
Given this:
<%= f.collection_select :role_id, @role, :id, :name %>
Is there an easy way to humanize or titleize the :name
, if it's stored as something like super_admin
? I tried human开发者_如何学编程ize(:name)
but that didn't seem to work.
A better way would be to add a method in the model 'role' which returns human name something like
class Role< ActiveRecord::Base
def human_name
humanize(name)
end
end
<%= f.collection_select :role_id, @role, :id, :human_name%>
精彩评论