When you call the new() function for example @variable = Object.new() all the coloumn name of Object are assigned to the variable except the id. The new() function apparently generates a new id for @variable.

I was having trouble with this, in a scenario when you pass a parameter to the new() function as:

@variable = Object.new(params['object_name'])

This is mostly used in the case of a form submission, all the information from the post stream is copied into @variable from the params variable. All the attributes are copied except the id attribute. Hence you'd have to explicitly assign the id.

Resulting code:

@variable = Object.new(params['object_name'])
@variable.id = params['object_name']['id']

EDIT: @params has been depracated to params, I've made the changes.