This may be as much a pure HTML question as a Rails question, but I’m
just feeling my way through ActionView and need all the help I can get!
The scenario: A user types a street address into a form and hits return.
My app uses Google geocoding services (sweet) to resolve the user input
into a full street address. It may resolve into zero addresses (no
match), one address (exact match), or multiple addresses (partial
match).
From this, I want to render a form that lets the user verify his or her
street address. In the zero match case, I can flash an error message
saying there were no matches and re-render the original form. With one
or more matches, I want a “this is my address” button next to each
resolved address to let the user verify his or her address:
type your address: 15 wayland street
[this is my address] 15 wayland st, atlanta, ny 14808
[this is my address] 15 wayland st, boston, ma 02125
[this is my address] 15 wayland st, sherrill, ny 13461
What I’m not at all sure about is the parameters to add to each submit
button. I want the button label to say “this is my address”, but pass a
fully resolved address to the server depending on which button is
pushed. I tried :name => candidate.full_address, :value => “this is my
address” – I could make that work, but the parameters passed to my
server are ‘backwards’ (key = full_address, value = “this is my
address”).
So my question is: how would you structure a Rails form to do this?
Assume @premise is the controller, and that @candidates is a list of
candidate addresses.
TIA.