diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/quotes_controller.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index 58af7bb..f7445da 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb | |||
@@ -63,6 +63,12 @@ class QuotesController < ApplicationController | |||
63 | @quote = Quote.new(quote_params) | 63 | @quote = Quote.new(quote_params) |
64 | @quote.submitter = nil if @quote.submitter.empty? | 64 | @quote.submitter = nil if @quote.submitter.empty? |
65 | 65 | ||
66 | unless @quote.valid? | ||
67 | flash.alert = "Error submitting quote." | ||
68 | render :new | ||
69 | return | ||
70 | end | ||
71 | |||
66 | if user_signed_in? | 72 | if user_signed_in? |
67 | @quote.state = :published | 73 | @quote.state = :published |
68 | @quote.save! | 74 | @quote.save! |
@@ -70,8 +76,13 @@ class QuotesController < ApplicationController | |||
70 | flash[:notice] = "Thank you for submitting your quote!" | 76 | flash[:notice] = "Thank you for submitting your quote!" |
71 | redirect_to @quote | 77 | redirect_to @quote |
72 | else | 78 | else |
73 | flash[:error] = "There was an error." | 79 | @quote.state = :pending |
74 | render :new | 80 | @quote.save! |
81 | |||
82 | QuoteMailer.with(quote: @quote).pending_quote_email.deliver_later | ||
83 | |||
84 | flash[:notice] = "Your quote has been submitted and is pending moderation." | ||
85 | redirect_to new_quote_url | ||
75 | end | 86 | end |
76 | end | 87 | end |
77 | 88 | ||