Created
February 6, 2014 11:15
-
-
Save victorcreed/8842304 to your computer and use it in GitHub Desktop.
just for fun.... converted it into 1 line
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 NewsLettersController < ApplicationController | |
def send_news_letter | |
#if params[:send_news_letter][:email].present? | |
# @user = User.new params[:send_news_letter] | |
# @user.save validate: false | |
# Notifier.send_news_letter(@user).deliver | |
# redirect_to root_path, notice: "Thanks for sharing. We'll keep you in the loop!" | |
#else | |
#redirect_to root_path, error: "Please provide your email for the newsletter." | |
redirect_to *lambda {lambda{ @user = User.new( params[:send_news_letter]); @user.save(validate: false); Notifier.send_news_letter(@user).deliver }.call if params[:send_news_letter][:email].present? ; return [root_path, (params[:send_news_letter][:email].present? ? { notice: "Thanks for sharing. We'll keep you in the loop!" } : {error: "Please provide your email for the news letter!"})] }.call | |
#end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment