Hi
I have the following scenario:
A company has an account.
Each account has many users.
Users can make posts.
Posts will obviously have an .id field that
autoincrements. However, I want a field, say post_number, that
increments within the :scope => :account_id, so all the posts within
a company has numbers that follow on each other.
Problem. Two users from the same account could be posting at the same time. I need a way to make sure the post_number is unique for each account and increments from 1.
If you are using a mysql database - what would be the best way of doing this? Would you have to do the saving within a transaction?
Regards
Ivor