ruby on rails - Giving a user a 'primary key' inside their data domain -
i have rails app consists of lots of accounts.
inside these accounts users can create tickets.
what best way give each ticket id sequential inside account?
obviously managing id's myself seems initial answer, seems filled sort of edge cases cause issues (for instance, 2 tickets writing down db @ once...)
i think you'll end managing them - i've implemented similar previously, account stored 'current_ticket_id' , when ticket (for example) get's created still stored global pk observer assigns friendly_ticket_id , increments 1 on account model next time round. can use friendly_ticket_id scoped account via urls make sure right ticket back.
Comments
Post a Comment