Implementing a credit-based system

CPerry
Fri, 01 Aug 2008 12:45:38 -0000

Hey all, fairly new to Rails here and I am currently building my first
Rails app.

I am building an app that will require users to purchase credits in
order to post items on the site. These credits will be purchased in
blocks of credits like 5, 10, 20, etc. (similar to istockphoto.com).

Here is how I picture setting up the credits in my app.

Credits Model - This model would determine the different credit
packages (5,10,20) along with the price of each credit package.

This model would "belong to" User and the User "has many"
Credits,
right?

I then assume that the controller for my credits is where I would
handle the logic of adding credits to the user accounts, making sure
the credit is deducted when they list an item, and keeping track of
how many credits a user has at any given time. I also assume that as
credits are purchased, and the user needs to be emailed notification
of that purchase, that logic would also live in this same controller,
right?

Am I on the right track here as far as mapping out what goes where? I
am really loving Rails so far, I am just having a bit of a hard time
wrapping my head around where logic goes and what handles what and how
they all tie in together!

I appreciate any help or feedback that you guys can give me! Thanks!