Overriding default values - model advice

I am looking for some advice in putting together the proper models and
relationships in my application. My concern revolves around the
requirement to have default prices, but allow them to be optionally
overridable.

The application involves clients choosing from menus of various
dishes. Several menus are predefined and the client chooses the one
they want to use.

The models I’ve identified are Dish, Menu & Client. Menu has_many
dishes and Client has_one menu. Dishes have a name and a default
price. So far so good.

Now the puzzle: What’s the best way to model the overriding of a
dish’s price on a client by client basis? Clients are related to
dishes through menus, but menus are shared across clients.

I think I need another join table which stores dish_id, client_id and
price. But then how to describe the relationship to rails?

Thanks for any advice on this.

It would look like the menu thing. Only that it can be multiple
prices.
Can a Client have only one Menu? Seems a bit strange, but may depend
on your app.

Say you call the model ClientPrices

Client model:
has_many :client_prices

Dishes:
has_many :client_prices

That’s all to it as far as I can see…

Thanks for the reply. Yes the app calls for just one menu per client.

I see where you’re going here. I think the logic below would complete
things.

Client.menu.dishes each do |dish|
price = ClientPrices.find_by_client_and_dish(@client.id, dish.id)
|| dish.default_price
end

Thanks for the advice and let me know if you see any improvements!