I have an item model that has a name and a price (int). How could I make it so that when the user selects the name from a drop down the price will automatically be added to the db?
My name drop down is populated by a hash of this format: THINGS = { 'Item 1' => 'item1', 'Item 2' => 'item2', etc } I'm thinking that a large switch statement where I do something like
case s
when hammer
item.price = 15
when nails
item.price = 5
when screwdriver
item.price = 7
end
But I'm not sure where I would put this switch.
Thanks