add response(temp)

This commit is contained in:
thomaschen 2013-09-10 17:54:18 +08:00 committed by chris
parent da40c2b669
commit cc7a4ffb6d
4 changed files with 29 additions and 8 deletions

View File

@ -26,18 +26,19 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController
end
def update
@ask_question = AskQuestion.find(params[:ask_question_id])
@ask_reply = AskReply.find(params[:id])
@ask_reply.update_attributes(params[:ask_reply])
if @ask_reply.send_email?
Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id)
end
##
send_request
send_request(@ask_question)
##
redirect_to panel_ask_back_end_ask_questions_path # , notice: t('ask.reply_success')
end
def send_request
def send_request(current_question)
require 'net/http'
require 'uri'
require 'json'
@ -52,11 +53,20 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data(body)
response = http.request(request)
puts "Response #{response.code} #{response.message}: #{response.body}"
flash[:notice] = response.body
# puts "Response #{response.code} #{response.message}: #{response.body}"
if response.code == "200"
uri = URI.parse("http://localhost:4000/panel/ask/back_end/ask_requests/transfer_request")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
body = {
'title' => current_question.title
}
request.set_form_data(body)
response = http.request(request)
flash[:notice] = response.body
end
# flash[:notice] = response.body
# flash[:notice] = "Response #{response.code} #{response.message}: #{response.body}"
end

View File

@ -4,7 +4,17 @@ class Panel::Ask::BackEnd::AskRequestsController < OrbitBackendController
include OrbitControllerLib::DivisionForDisable
def auth_request
params.merge!({'c' => '789'})
params={'c' => '456' }
render :json => "#{params}"
end
def transfer_request
# @ask_question = AskQuestion.all
# x = @ask_question.count
# params={'d' => x }
@transfered_question=AskQuestion.new(:title=>params[:title])
@transfered_question.save
render :json => "#{params}"
end
end

View File

@ -15,8 +15,9 @@ Rails.application.routes.draw do
resources :ask_categories
resources :ask_acknowledgements
resources :ask_admins
match "ask_requests/auth_request" => "ask_requests#auth_request", :as => 'auth_request'
match "ask_requests/transfer_request" => "ask_requests#transfer_request", :as => 'transfer_request'
end
namespace :front_end do