I’m building an application that allows users to purchase ads to display within a print publication. The ads are listed in a section of the publication in a manner similar to the yellow pages, where you can choose a category under which to display your listing.
Each ad’s price is determined by a number of factors. The listing starts with a ‘base’ price. Ads that go over a certain number of characters will have an added cost (e.g., 0-74 chars included, 75-150 chars $20, 150-200 chars $40), Ads can optionally display a small logo for an added charge, and you can receive discounts by running the same ad in multiple publications. (e.g., if you run your ad in the next two issues you get a 20% discount per ad, run it in the next four issues and get a 30% discount per ad)
I’m trying to think of different ways of modeling this behavior. I thought about doing something similar to this accepted answer, combined with the ActiveRecord:store to save conditions for each variation, but I’m not sure if that’s a great idea.
I’d like something semi-flexible because the client seems to try lots of different pricing tweaks every issue. Thanks in advance for any insight.
Here you have a class Advertisement, with a length (calculated), body, cost (calculated), owner, icon, start and end date. Use the body to determine the length.Use the icon, end – start dates, and length to calculate the cost. I’d do all this in the class methods.
Now you might want to consider having an advertisement owner table etc, that much is up to you.