Add ask fail message and success redirect fix

This commit is contained in:
Bernie Chiu 2013-10-01 16:09:43 +08:00
parent 3eeda5410c
commit 88c8ca68d0
8 changed files with 19 additions and 8 deletions

View File

@ -14,18 +14,22 @@ class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController
def create
@ask_question = AskQuestion.new(params[:ask_question])
if gotcha_valid? && @ask_question.save
@acknowledgement = AskAcknowledgement.last
@acknowledgement = AskAcknowledgement.last
@ask_acknowledgement = AskAcknowledgement.first || AskAcknowlegement.new
#@ask_question.save
redirect_to root_path
AskAdmin.all.each do |ask_admin|
AskMailer.notice(ask_admin, @ask_question).deliver
Resque.enqueue(SendAskNoticeMail, ask_admin.id, @ask_question.id)
end
# redirect_to panel_ask_front_end_thank_you_path
# Render to create.js.erb
respond_to do |format|
format.js
# format.js { render :thank_you, notice: 'Your question has been successfully sent.' }
end
else
# Render to index.js.erb
respond_to do |format|
format.js { render :index }
end
end
end
@ -43,4 +47,7 @@ class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController
end
@item = Page.find(params[:page_id]) rescue nil
end
def sorry
end
end

View File

@ -1 +1 @@
window.location.href= "<%= panel_ask_front_end_thank_you_path %>"
window.location.href = "<%= panel_ask_front_end_thank_you_path %>";

View File

@ -22,8 +22,7 @@ $(document).ready(function(){
}).bind("ajaxError", function() {
$(this).hide();
});
});
});
</script>
<div id="spinner" class="spinner" style="display:none;">

View File

@ -0,0 +1 @@
window.location.href = "<%= panel_ask_front_end_sorry_path %>";

View File

@ -0,0 +1 @@
<h3><%= t(:ask_fail, :scope => :ask) %> !</h3>

View File

@ -1,5 +1,6 @@
en:
ask:
ask_fail: Something went wrong
ask: Ask
export: Export
reply: Reply

View File

@ -3,6 +3,7 @@ zh_tw:
errors:
verification_failed: 驗證碼錯誤
ask:
ask_fail: 寄送失敗
ask: 發問
export: 匯出
reply: 回覆

View File

@ -22,6 +22,7 @@ Rails.application.routes.draw do
namespace :front_end do
match "ask_questions/thank_you" => "ask_questions#thank_you", :as => 'thank_you'
match "ask_questions/sorry" => "ask_questions#sorry", :as => 'sorry'
resources :ask_questions
end
end