How to remove a field from params[:something]

后端 未结 5 1207
野性不改
野性不改 2020-12-22 20:21

My registration form, which is a form for the Users model, takes a string value for company. However, I have just made a change such that users belongs_to companies. Therefo

5条回答
  •  温柔的废话
    2020-12-22 21:04

    You should probably be using hash.except

    class MyController < ApplicationController
      def explore_session_params
        params[:explore_session].except(:account_id, :creator)
      end
    end
    

    It accomplishes 2 things: allows you to exclude more than 1 key at a time, and doesn't modify the original hash.

提交回复
热议问题