この質問のタイトルを正しく述べたと思いますが、これが問題です:
私のSurveysControllerには次のものがあります-
def pull_responses
call= "/api/v2/surveys/"
auth = {:username => "test", :password => "password"}
url = HTTParty.get("https://fluidsurveys.com#{call}",
:basic_auth => auth,
:headers => { 'ContentType' => 'application/json' } )
response = JSON.parse(url.body)
survey_ids = response["surveys"].map { |s| s["id"] }
survey_ids.each do |x|
call= "/api/v2/surveys/#{x}/responses/?_completed=1"
auth = {:username => "test", :password => "password"}
url = HTTParty.get("https://Fluidsurveys.com#{call}",
:basic_auth => auth,
:headers => { 'ContentType' => 'application/json' } )
response = JSON.parse(url.body)
response_count = response["count"]
Survey.create(y: response_count)
end
end
helper_method :pull_responses
私がやろうとしているのは、変数response_count
を調査ビューに入れることだけです。必要ないかもしれませんがSurvey.create(y: response_count)
、これはこれを機能させるための私の試みの1つでした。基本的に、これをビューに書きたいだけです:
puts response_count
その応答をビューに入れる適切な方法は何ですか?