我有這個collection_select <%= collection_select(:template, :template_id, @templates, :id, :name) %>
,我想基本上調用:name.humanize
,但顯然這是行不通的。 (?哈希屬性)Rails如何調用助手,如.humanize上的屬性collection_select
我如何可以調用的方法,如.humanize
上collection_select的屬性
編輯
下面是從我的控制器的一個片段:
@templates = Template.select(:name).group(:name)
p "templates = #{@templates}"
這裏的控制檯中顯示的內容:
"templates = #<ActiveRecord::Relation:0x007f84451b7af8>"
建設@templates對象時,我會做這個之前,做你自己,通過準備您的數據。 – Candide
是的,贊同@Candide,我可能會有另一個幫助做這種事情的屬性。 –
您可以詳細說明嗎?也許有一些代碼? – Catfish