Skip to content

Instantly share code, notes, and snippets.

@tonkec
Created May 6, 2016 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonkec/955a3f836939ec3f787bde31e345dc21 to your computer and use it in GitHub Desktop.
Save tonkec/955a3f836939ec3f787bde31e345dc21 to your computer and use it in GitHub Desktop.
class PostMailer < ApplicationMailer
def new_post_email(user_id)
puts "MAILER!!"
@user = User.find_by_id(user_id)
mail(to: @user.email, subject: 'New question has been asked!')
end
end
def create
@post = current_user.posts.build(post_params)
if @post.save(post_params)
flash.now[:success] = "Post successfully created"
redirect_to post_path(@post)
PostsWorker.perform_in(30.seconds, User.first.id)
else
render "new"
end
end
class PostsWorker
include Sidekiq::Worker
def perform(user_id)
puts user_id + "asdsad"
puts "I am worker!"
PostMailer.new_post_email(user_id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment