I made an application in rails 3.0.9…in that application I have one form which is having an address field. Now first time if user enters the address field(say “ABC”) status should be 1, but when another time user is entering new address(say “XYZ”) and then submits ts status should be 1 and the ABC status should be 0.
If now user enters another address say “PQR” and submits then its status should be 1 and XYZ status should be 0 and so on.
For example, there are 10 address in database and first 9 address are having status 0 and 10th is having 1. If user enters another address then 11th should be 1 and 10th should be 0.
I don’t know how to change value in runtime in table…
I made an application in rails 3.0.9…in that application I have one form which
Share
This can be done with ActiveRecord’s update_all method. Simply define a callback in your model:
However, as blackbird07 pointed out, you probably need to rethink how you’re using addresses in your application, and simply fetch the most recently updated address, rather than updating every field of a table.