开发者

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%>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜