def update_user(id, first_name, last_name, age, address, is_admin)
user = User.find(id)
user.update(
first_name: first_name,
last_name: last_name,
age: age,
address: address,
is_admin: is_admin
)
end
update_user(1, "John", "Doe", 25, "Baker Street", false)
def update_user(params = {})
user = User.find(params[:id])
user.update(
first_name: params[:first_name],
last_name: params[:last_name],
age: params[:age],
address: params[:address],
is_admin: params.fetch(:is_admin, false)
)
end
user_params = {
id: 1,
first_name: "John",
last_name: "Doe",
age: 25,
address: "Baker Street"
}
update_user(user_params)