instance method then

Ruby on Rails 7.1.6

Since v7.1.6

Available in: v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

then(&block)

Returns a new ActiveRecord::Promise that will apply the passed block when the value is accessed:

Post.async_pick(:title).then { |title| title.upcase }.value
# => "POST TITLE"

Parameters

block block
Source
# File activerecord/lib/active_record/promise.rb, line 36
    def then(&block)
      Promise.new(@future_result, @block ? @block >> block : block)
    end

Defined in activerecord/lib/active_record/promise.rb line 36 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Promise

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close