Saving enum from select in Rails 4.1

后端 未结 8 1992
难免孤独
难免孤独 2020-11-28 02:31

I am using the enums in Rails 4.1 to keep track of colors of wine.

Wine.rb

class Wine < ActiveRecord::Base
    enum color: [:red,         


        
8条回答
  •  心在旅途
    2020-11-28 03:18

    No need converting the enum hash to array with to_a. This suffice:

    f.select :color, Wine.colors.map { |key, value| [key.humanize, key] }
    

提交回复
热议问题