Попытка реализовать запись создания, если она не существует, в Active Record.
В настоящее время используется:
@student = Student.where(:user_id => current_user.id).first
if @student
Student.destroy_all(:user_id => current_user.id)
end
Student = Student.new(:user_id => current_user.id, :department => 1
)
Student.save!
Каким будет правильный способ обновления записи, если она существует, или создать ее?