instance method
slice
Ruby on Rails 7.1.6
Since v4.0.13Signature
slice(*methods)
Returns a hash of the given methods with their names as keys and returned values as values.
topic = Topic.new(title: "Budget", author_name: "Jason")
topic.slice(:title, :author_name)
=> { "title" => "Budget", "author_name" => "Jason" }
Source
# File activerecord/lib/active_record/core.rb, line 562
Defined in activerecord/lib/active_record/core.rb line 562
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Core