instance method
slice
Ruby on Rails 7.2.3
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 579
Defined in activerecord/lib/active_record/core.rb line 579
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Core