Created
May 6, 2016 12:41
-
-
Save tonkec/955a3f836939ec3f787bde31e345dc21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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