Skip to content

Instantly share code, notes, and snippets.

View superhighfives's full-sized avatar

Charlie Gleason superhighfives

View GitHub Profile
@superhighfives
superhighfives / middleware.rb
Last active February 28, 2017 18:50
Rails 5 API + ActiveAdmin + create-react-app on Heroku
config.middleware.use Rack::MethodOverride
config.middleware.use ActionDispatch::Flash
config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore
@superhighfives
superhighfives / application.rb
Last active March 2, 2017 18:06
Rails 5 API + ActiveAdmin + create-react-app on Heroku
require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
@superhighfives
superhighfives / package.json
Last active March 2, 2017 18:06
Rails 5 API + ActiveAdmin + create-react-app on Heroku
{
"name": "list-of-ingredients",
"engines": {
"node": "6.3.1"
},
"scripts": {
"build": "cd client && npm install && npm run build && cd ..",
"deploy": "cp -a client/build/. public/",
"postinstall": "npm run build && npm run deploy && echo 'Client built!'"
}
@superhighfives
superhighfives / package.json
Last active March 2, 2017 23:39
Rails 5 API + ActiveAdmin + create-react-app on Heroku
{
"name": "client",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:3001",
"devDependencies": {
"react-scripts": "0.9.0",
},
"dependencies": {
"react": "^15.4.2",
@superhighfives
superhighfives / drinks_controller.rb
Last active March 2, 2017 18:05
Rails 5 API + ActiveAdmin + create-react-app on Heroku
class DrinksController < ApplicationController
def show
render json: {
title: "Sparkling Negroni",
ingredients: [
"⅓ oz. Campari",
"⅓ oz. gin",
"⅓ oz. sweet vermouth",
"Chilled prosecco, or other sparkling wine, for topping",
"Orange peel twist (optional)"
@superhighfives
superhighfives / routes.rb
Last active March 3, 2017 00:12
Rails 5 API + ActiveAdmin + create-react-app on Heroku
Rails.application.routes.draw do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
scope '/api' do
resources :drinks
end
end
@superhighfives
superhighfives / Procfile.dev
Last active February 28, 2017 19:44
Rails 5 API + ActiveAdmin + create-react-app on Heroku
web: cd client && PORT=3000 npm start
api: PORT=3001 && bundle exec rails s
@superhighfives
superhighfives / App.js
Last active March 6, 2017 14:46
Rails 5 API + ActiveAdmin + create-react-app on Heroku
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
componentDidMount() {
window.fetch('api/drinks')
.then(response => response.json())
.then(json => console.log(json))
.catch(error => console.log(error))
@superhighfives
superhighfives / shell
Last active February 28, 2017 19:44
Rails 5 API + ActiveAdmin + create-react-app on Heroku
heroku buildpacks:add heroku/nodejs --index 1
heroku buildpacks:add heroku/ruby --index 2
@superhighfives
superhighfives / .gitignore
Created February 28, 2017 19:40
Rails 5 API + ActiveAdmin + create-react-app on Heroku Raw
# See https://help.github.com/ignore-files/ for more about ignoring files.
# dependencies
/node_modules
# testing
/coverage
# misc
.DS_Store