Last object edited appearing in form on new object page

Dinshaw Gobhai wrote:

  @sport_field = SportField.find_by_id(params[:id]) ||

  #log output below
  SportField Load (0.007752) SELECT * FROM sport_fields WHERE (sport_fields.`id` IS NULL ) LIMIT 1
So it selects the opject with ID NULL but finds and logs a id of 40 (in this case)

Which database adapter and Rails version are you using?

In any case it'd be better to switch to:

@sport_field = params[:id] ? SportField.find(params[:id]) :

Dinshaw Gobhai wrote:

Hi and thanks for the reply.
I am using mysql and i checked out the head of the repository into vendor at the begining of this month.

Here is something else strange, if you refreash the page that has the phantom object's info, it goes away and acts as if (correctly) I was createing a new object.

The reason for what you're seeing was just described in another thread:

So change your code in the way suggested in this post, which is
the same as I suggested in my original reply.