instance method
slice
Ruby on Rails 8.1.2
Since v7.1.6Signature
slice(*methods)
Returns a hash of the given methods with their names as keys and returned values as values.
person = Person.new(id: 1, name: "bob") person.slice(:id, :name) # => { "id" => 1, "name" => "bob" }
Source
# File activemodel/lib/active_model/model.rb, line 48
Defined in activemodel/lib/active_model/model.rb line 48
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Model