Today I Learned

A Hashrocket project

Ready to join Hashrocket? Find Openings here and apply today.

CurrentAttributes.set takes a block

CurrentAttributes.set takes a block that will enclose values during the block call, perfect for background jobs:

class Chat::PublicationJob < ApplicationJob
  def perform(attributes, room_number, creator)
    Current.set(person: creator) do
      Chat::Publisher.publish(attributes: attributes, room_number: room_number)
    end
  end
end
Looking for help? Hashrocket has been an industry leader in Ruby on Rails since 2008. Rails is a core skill for each developer at Hashrocket, and we'd love to take a look at your project. Contact us and find out how we can help you.