diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-21 12:36:21 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-21 12:36:21 -0400 |
commit | a39b0711eefb07fb75294a68d635fb1323d24cf3 (patch) | |
tree | 04f234347bb4fe2a0ce4a83b48c1bb121c620a9b /app/controllers/quotes_controller.rb | |
parent | 3bf957736f7ba79a0a0f30ace996ba05b0f33f15 (diff) | |
download | thoughts-a39b0711eefb07fb75294a68d635fb1323d24cf3.tar.gz thoughts-a39b0711eefb07fb75294a68d635fb1323d24cf3.tar.bz2 thoughts-a39b0711eefb07fb75294a68d635fb1323d24cf3.zip |
Quotes can be submitted, although it is not encouraged
Diffstat (limited to 'app/controllers/quotes_controller.rb')
-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 | ||