diff --git a/app/controllers/api/v1/partners_controller.rb b/app/controllers/api/v1/partners_controller.rb new file mode 100644 index 0000000..5a43505 --- /dev/null +++ b/app/controllers/api/v1/partners_controller.rb @@ -0,0 +1,42 @@ +module Api + module V1 + class PartnersController < ApiController + def index + render json: Partner.all + end + + def create + partner = Partner.new(partner_params) + if partner.save + render json: status: 200 + else + render json: status: 500 + end + end + + def update + partner = Partner.find(params[:id]) + if partner.update(partner_params) + render json: status: 200 + else + render json: status: 500 + end + end + + def destroy + partner = Partner.find(params[:id]) + if partner.delete + render json: status: 200 + else + render json: status: 500 + end + end + + private + + def partner_params + params.require(:partner).permit() + end + end + end +end diff --git a/app/models/partner.rb b/app/models/partner.rb new file mode 100644 index 0000000..6a58e97 --- /dev/null +++ b/app/models/partner.rb @@ -0,0 +1,2 @@ +class Partner < ActiveRecord::Base +end diff --git a/config/routes.rb b/config/routes.rb index d05e1be..b1b8ac2 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,6 +32,8 @@ resources :indicators, only: [:index, :show] do end + resources :partners + get '/places', to: 'geographies#index', as: 'community_areas' get '/place/:geo_slug', to: 'geographies#show', as: 'community_area' get '/place/:geo_slug/resources(/:dataset_slug)', to: 'geographies#resources_json', as: 'community_area_resources' diff --git a/db/migrate/20180722014457_create_partners.rb b/db/migrate/20180722014457_create_partners.rb new file mode 100644 index 0000000..0cdf290 --- /dev/null +++ b/db/migrate/20180722014457_create_partners.rb @@ -0,0 +1,13 @@ +class CreatePartners < ActiveRecord::Migration + def change + create_table :partners do |t| + t.string :title + t.string :description + t.string :img_src_url + t.string :img_alt + t.string :image_url + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 053b3b2..05dade5 100755 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170915190057) do +ActiveRecord::Schema.define(version: 20180722014457) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -163,6 +163,16 @@ add_index "intervention_locations", ["geography_id"], name: "index_intervention_locations_on_geography_id", using: :btree + create_table "partners", force: :cascade do |t| + t.string "title" + t.string "description" + t.string "img_src_url" + t.string "img_alt" + t.string "image_url" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "provider_stats", force: :cascade do |t| t.integer "provider_id" t.string "stat_type" diff --git a/spec/controllers/api/v1/partners_controller_spec.rb b/spec/controllers/api/v1/partners_controller_spec.rb new file mode 100644 index 0000000..3ca17f3 --- /dev/null +++ b/spec/controllers/api/v1/partners_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Api::V1::PartnersController, type: :controller do + +end diff --git a/spec/models/partner_spec.rb b/spec/models/partner_spec.rb new file mode 100644 index 0000000..06cff9d --- /dev/null +++ b/spec/models/partner_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Partner, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end