
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Drip engine, for Ruby on Rails.
Because drip
was taken and moist
was available.
There is also a measurable amount of people who hate the word moist. Which results in a poor adoption strategy. In turn, fewer stars. Conclusion: recruiters won't bother me?
Goals?
Maybe, here's the gist:
# Create a campaign:
::Moist::Campaign.create(name: "Abandoned cart", slug: "cart")
# Add `moist` to mailer:
class AbandonedCartMailer < ActionMailer::Base
moist :you_forgot_something, campaign: :cart, step: 1, delay: 1.hour
def you_forgot_something(cart)
# ...
end
moist :selling_out_soon, campaign: :cart, step: 2, delay: 4.hours
def selling_out_soon(cart)
# ...
end
end
# Add to a drip campaign:
::Moist::Campaign.subscribe(cart, user: cart.user).to(:cart)
# Remove from a drip campaign:
::Moist::Campaign.unsubscribe(cart, user: cart.user).from(:cart)
Add this line to your application's Gemfile:
gem 'moist'
And then execute:
$ bundle
Bring in the initializer and migrations:
$ rails g moist:setup
And do the migrate:
$ rails db:migrate
How to use Moist
to create an abandoned cart drip campaign.
Moist::Campaign
.Moist::Campaign.create(name: "Abandoned cart
, slug: "cart")`
The slug
used here will be referenced later. Note it.
moist
in your mailer to create steps.You'll need to define @moist_subscriber
and @moist_user
in each mailer. This tells Moist what Moist::Mailing
to
associate with the mailer.
class AbandonedCartMailer < ActionMailer::Base
moist :you_forgot_something, campaign: :cart, step: 1, delay: 1.hour
def you_forgot_something(cart)
@cart = cart
@moist_subscriber = cart
@moist_user = cart.user
mail(subject: "You forgot something...", to: @cart.user.email)
end
moist :free_shipping_if_you_order_now, campaign: :cart, step: 2, delay: 2.days
def free_shipping_if_you_order_now(cart)
@cart = cart
@moist_subscriber = cart
@moist_user = cart.user
mail(subject: "Free shipping? Yep. Complete your purchase right meow!", to: @cart.user.email)
end
end
In these mailer methods, make sure you assign a @moist_subscriber
and a @moist_user
. If you don't, bad things will happen.
@cart
to the campaignProbably a background job.
class AbandonedCartJob < ApplicationJob
TIME_TO_LIVE = 1.hour
def perform
Cart.where(checked_out: false).where('updated_at < ?', TIME_TO_LIVE.ago).each do |cart|
::Moist::Campaign.subscribe(cart, user: cart.user).to(:cart)
end
end
end
This manages the mailers and the drips.
class MoistSchedulerJob < ApplicationJob
def perform
::Moist::Scheduler.run
end
end
All done. Some nice-to-haves:
class Cart
has_moist_campaigns
end
Gives you
@cart.moist_campaigns
class User
acts_as_moist_user
end
Gives you:
@user.moist_subscriptions
Three core concepts:
This is just an object for reference.
This joins a Campaign
to a subscriber
(polymorphic anything), and a user
. In theory, a user
can have many moist_campaign_subscribers
,
which would relate it to objects that belong to a user
.
This is useful if you have an Order
object and a Subscription
object that you want to create different campaigns for.
Takes your ActionMailer moist
calls and turns them into database records. They have send_at
and sent_at
columns,
in addition to information about the mailers they belong to.
Just do it.
delay
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that moist demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.