Trying to implement an create if not exists else update record in Active Record.
Currently using:
@student = Student.where(:user_id
In Rails 5
Student. find_or_initialize_by(:user_id => current_user.id). update(:department => 1)
(with all credit taken from @Zorayr answer).