Hello,
Ruby on Rails provides the clone
method, which creates a shallow clone of the object. In your case, you could use it like that:
@previous_student = @student.clone
The documentation of the clone
method states:
Returns a clone of the record that
hasn’t been assigned an id yet and is
treated as a new record. Note that
this is a “shallow” clone: it copies
the object’s attributes only, not its
associations. The extent of a “deep”
clone is application-specific and is
therefore left to the application to
implement according to its need.
http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001848
As stated in the documentation, you should maybe override the clone
method, to implement your own cloning, if you use associations in the Student
model.
Cheers