Last object edited appearing in form on new object page

Dinshaw Gobhai wrote:

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

  #log output below
  logger.error(@sport_field.id)
...
  SportField Load (0.007752) SELECT * FROM sport_fields WHERE (sport_fields.`id` IS NULL ) LIMIT 1
41
------
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]) : SportField.new

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:
    http://www.ruby-forum.com/topic/70940#164187

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