如何在collection_radio_buttons中使用枚举

时间:2016-04-04 01:50:50

标签: ruby-on-rails ruby-on-rails-4

给定模型枚举status,如何在collection_radio_buttons中使用?

class Project < ActiveRecord::Base
  enum status: [:rejected, :approved, :pending]
end

1 个答案:

答案 0 :(得分:4)

你可以做类似下面的事情

<%= collection_radio_buttons(:project, :status, Project.statuses, :first, :first)%>