0

在我的 ruby​​ on rails 项目中,我在update.

undefined local variable or method ` ' for #<ProfileController:0x007fd904dc8568>.

但是,我在控制器中找不到(` ')

配置文件控制器#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
4

1 回答 1

2

这可能是您将其视为空间的隐形字符,但 ruby​​ 不是。通过在体面的编辑器中选择文本进行检查,这将显示它们是空格还是其他。

于 2012-10-24T11:04:42.140 回答