added airtable routes
This commit is contained in:
parent
4d17e74d01
commit
e8f0a0b505
|
@ -1,29 +1,10 @@
|
|||
class TablesController < ApplicationController
|
||||
def recent_news
|
||||
render json: RecentNews.all.to_json
|
||||
end
|
||||
|
||||
def resources
|
||||
render json: Resources.all.to_json
|
||||
end
|
||||
|
||||
def support_services
|
||||
render json: SupportServices.all.to_json
|
||||
end
|
||||
|
||||
def gas_stations
|
||||
render json: GasStations.all.to_json
|
||||
end
|
||||
|
||||
def markets
|
||||
render json: Markets.all.to_json
|
||||
end
|
||||
|
||||
def shelters
|
||||
render json: Shelters.all.to_json
|
||||
end
|
||||
|
||||
def volunteering
|
||||
render json: Volunteering.all.to_json
|
||||
AirtableSheets.each do |k,v|
|
||||
define_method(k) do
|
||||
::Rails.cache.fetch("cache/#{k}", expires_in: 30.seconds) do
|
||||
render json: v.all.to_json
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1 +1,11 @@
|
|||
Airrecord.api_key = ENV['AIRTABLE_BASE']
|
||||
|
||||
AirtableSheets = {
|
||||
recent_news: RecentNews,
|
||||
resources: Resources,
|
||||
support_services: SupportServices,
|
||||
gas_stations: GasStations,
|
||||
markets: Markets,
|
||||
shelters: Shelters,
|
||||
volunteering: Volunteering,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Rails.application.routes.draw do
|
||||
['recent_news', 'resources', 'support_services', 'gas_stations', 'markets', 'shelters', 'volunteering'].each do |x|
|
||||
AirtableSheets.keys.each do |x|
|
||||
get "/#{x}", to: "tables##{x}"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue