How to lock the destroy action?

hi all.
Bus and Tickets/has_one, belongs_to/
Users and Tickets/has_many, belongs_to/
i want to realize next action:

“ticket.destroy.lock” if > bus.places*0.9
#if bus full for 90 %, users cant destroy their tickets (or bus never go

How correct to realize this locking action?

Validate the destroy action in the ticket model . More info Here

You could also use rails callbacks before_destroy

before_destroy :check_bus_status

def check_bus_status
return false if > bus.places*0.9

On Wed, Dec 17, 2014 at 8:41 PM, Vivek S. [email protected]

thank so much. again)

среда, 17 декабря 2014 г., 7:16:26 UTC-8 пользователь Vivek S.

On 17 December 2014 at 15:03, Psycho S. [email protected] wrote:

hi all.
Bus and Tickets/has_one, belongs_to/

Bus has_one ticket? I don’t think you will make much profit!