The general answer is "no", because the request that retrieves the list and the request that processes the selected item are totally separate. The only data that gets "passed" is the text strings that are sent to the browser and sent back (in the params hash) when the user submits the form or clicks a link.
So the typical idiom in the second action would be:
def set_choice @object = MyModel.find(params[:id]) end
Yes, that requires a db fetch (but it's quick).
If you *really* want to avoid the second query, you have two basic choices:
* Stash the object on the server between requests. The typical way is to save it in the session, since it automatically serializes/deserializes the object for you. * Serialize the object and include it in the form somewhere, and deserialize it from the parameters in the next request.
The session technique is easier and safer. (The other technique is risky, because the client could tamper with the object before returning it). But, you have additional problems:
* How do you keep the stash cleaned up? * What if the object is destroyed between request 1 and request 2? * You now cannot have a request 2 without a preceeding request 1 to load the stash
My advice is to follow the normal idioms and not worry about "performance" until it becomes an issue. There's lots of things you can do to improve performance without resorting to these kinds of techniques.