I'm not sure what this question is even called, but is it possible to have a list in a model via:
array of word
equipment %w[foo bar kimi etc...]
equipcost %i[10 35 85 etc...]
or
enum
enum equipment: { foo: 10,
bar: 35,
kimi: 83,
etc...
}
Then save multiple in an array i.e.
t.string "equipment_list", default: [], array: true
{ equipment_list => ["foo", "bar"] } or { equipment_list => [10, 35] }
Then when the object is called via @object.equipment_list, it references the the array of words or enum.
So in the view I say <%= @object.equipment_list %> and have the foo and bar display. Or if I'm in the model I can have a method that adds the values to get a total cost:
def cost
e = self.equipment_list
e.value
e.inject(:+)
end
Is there a ruby or rails way of doing this? The array of words way seems wrong and the emun way is only for a single value.
I found this but like they say it is an index not an actual value.