私の Ruby on Rails プロジェクトでは、このエラーがupdate
.
undefined local variable or method ` ' for #<ProfileController:0x007fd904dc8568>.
しかし、コントローラーに(` ')が見つかりません。
ProfileController#update
def update
unless params[:sport_name].nil?
ps_array = params[:sport_name]
level =[params[:level1],params[:level2],params[:level3]]
# play_sports id
sp_id = [params[:sp_id1], params[:sp_id2], params[:sp_id3]]
arr = [ps_array["1"],ps_array["2"],ps_array["3"]]
sport_id = [params[:sport_id1],params[:sport_id2],params[:sport_id3]]
check = [params[:check1], params[:check2], params[:check3]]
if @user.play_sports.count != 0
(0..2).each do |i|
if (check[i].to_i == 1)
PlaySport.where("id = ?", sp_id[i]).update_all(:is_active=>false)
# new save
newuser_ps = PlaySport.new
newuser_ps.sport_id = arr[i]
newuser_ps.is_active = true
newuser_ps.level = level[i]
newuser_ps.user_id = current_user.id
newuser_ps.save
end
end
else
(0..2).each do |i|
newuser_ps = PlaySport.new
newuser_ps.sport_id = arr[i]
newuser_ps.level = level[i]
newuser_ps.is_active = true
newuser_ps.user_id = current_user.id
newuser_ps.save
end
end
end
respond_to do |format|
end
end