“You can get the integer values for an enum from the class the enum is on: Model.sale_infos # Pluralized version of the enum attribute name That returns a hash like: { "plan_1" => 1, "plan_2" => 2 ... } You can then use the sale_info value from an instance of the Model class to access the integer
I have a enum in my Model that corresponds to column in the database. The enum looks like: enum sale_info: { plan_1: 1, plan_2: 2, plan_3: 3, plan_4: 4, plan_5: 5 } How can I get the integer value?...
“You can get the integer values for an enum from the class the enum is on: Model.sale_infos # Pluralized version of the enum attribute name That returns a hash like: { "plan_1" => 1, "plan_2" => 2 ... } You can then use the sale_info value from an instance of the Model class to access the integer
このブックマークにはスターがありません。
最初のスターをつけてみよう!
How get integer value from a enum in Rails?
I have a enum in my Model that corresponds to column in the database. The enum looks like: enum sale_info: { plan_1: 1, plan_2: 2, plan_3: 3, plan_4: 4, plan_5: 5 } How can I get the integer value?...
2 人がブックマーク・1 件のコメント
\ コメントが サクサク読める アプリです /