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.tickets > bus.places*0.9
#if bus full for 90 %, users cant destroy their tickets (or bus never go
to
race:))

How correct to realize this locking action?

Validate the destroy action in the ticket model . More info Here
http://stackoverflow.com/questions/123078/how-do-i-validate-on-destroy-in-rails

You could also use rails callbacks before_destroy

before_destroy :check_bus_status

private
def check_bus_status
return false if bus.tickets > bus.places*0.9
end

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!

Colin