I would use Rails caching, but you must think carefully about how to expire the cache. So:
@members = cached_members
private
def cached_members
@url = api_version_root+'/members/all?council='+session[:council]
Rails.cache.fetch("#{@url}/#{api_token_hash}/members", expires_in: 48.hours) do
response = RestClient.get @url, api_token_hash
(response.code == 200) && JSON.parse(response.body)
end
end
Then duplicate this in the answer controller, and @members will be populated from the cache. Now, of course it's poor practice to actually duplicate code, so pull it out into a helper mixin, like:
module MemberCache
def cached_members
@url = api_version_root+'/members/all?council='+session[:council]
Rails.cache.fetch("#{@url}/#{api_token_hash}/members", expires_in: 48.hours) do
response = RestClient.get @url, api_token_hash
(response.code == 200) && JSON.parse(response.body)
end
end
end
and include this in the two controllers:
require 'member_cache'
class ConnectController < ApplicationController
include MemberCache
end