collection_select, undefined method `map' for nil:NilClass

前端 未结 2 1462
情书的邮戳
情书的邮戳 2021-01-19 17:25

I added in the @user = User.new line to make sure it isn\'t nil. Which object is nil?

undefined method `map\' for nil:NilClass

Extracted source         


        
2条回答
  •  梦毁少年i
    2021-01-19 17:53

    You must to add @user_array to the actions: create, new, edit and update, the best way is using before_actions

    before_action :set_user_array , only: [:edit, :update, :new, :create]
    
     private
        def set_user_array 
          @user_array = User.all 
        end
    

提交回复
热议问题