Two fields in model but only need to store last field selected by user

Hi,

Please help me I have two fields in a form, One field stores photo, am using paperclip and another field stores link of picture from web. My problem is i have to store only one value of any field which user selects at last. Pls help me to do this.

I would use javascript and jquery to keep track of the user’s last selection. Then, also with javascript, intercept the submit and using ajax send the request containing only the last selection.