In this post, slice function is used to get only necessary elements of params. What would be the function I should use to exclude an element of params (such as user_id)?
Inspired in the sourcecode of except in Rails' ActiveSupport
You can do the same without requiring active_support/core_ext/hash/except
active_support/core_ext/hash/except
# h.slice( * h.keys - [k1, k2...] ) # Example: h = { a: 1, b: 2, c: 3, d: 4 } h.slice( * h.keys - [:b, :c] ) # => { a: 1, d: 4}