Skip to content

Instantly share code, notes, and snippets.

View superhighfives's full-sized avatar

Charlie Gleason superhighfives

View GitHub Profile
@superhighfives
superhighfives / ingredient.rb
Last active March 6, 2017 17:08
Rails 5 API + ActiveAdmin + create-react-app on Heroku
ActiveAdmin.register Ingredient do
permit_params :description, :drink_id
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
@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 / app.js
Last active March 6, 2017 14:46
Rails 5 API + ActiveAdmin + create-react-app on Heroku
import React, { Component } from 'react'
import { Container, Header, Segment, Button, Icon, Dimmer, Loader, Divider } from 'semantic-ui-react'
class App extends Component {
constructor () {
super()
this.state = {}
this.getDrinks = this.getDrinks.bind(this)
this.getDrink = this.getDrink.bind(this)
}
@superhighfives
superhighfives / package.json
Last active March 6, 2017 14:36
Rails 5 API + ActiveAdmin + create-react-app on Heroku
{
"name": "list-of-ingredients-client",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:3001",
"dependencies": {
"react-scripts": "0.9.3",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"semantic-ui-css": "^2.2.9",
@superhighfives
superhighfives / start.rake
Last active March 4, 2017 14:35
Rails 5 API + ActiveAdmin + create-react-app on Heroku
namespace :start do
task :development do
exec 'foreman start -f Procfile.dev'
end
desc 'Start production server'
task :production do
exec 'NPM_CONFIG_PRODUCTION=true npm run postinstall && foreman start'
end
end
@superhighfives
superhighfives / drinks_controller.rb
Last active March 4, 2017 13:10
Rails 5 API + ActiveAdmin + create-react-app on Heroku
class DrinksController < ApiController
# GET /drinks
def index
@drinks = Drink.select("id, title").all
render json: @drinks.to_json
end
# GET /drinks/:id
def show
@drink = Drink.find(params[:id])
@superhighfives
superhighfives / ingredients_controller.rb
Last active March 4, 2017 13:10
Rails 5 API + ActiveAdmin + create-react-app on Heroku
class IngredientsController < ApiController
end
@superhighfives
superhighfives / example_controller.rb
Created March 4, 2017 13:07
Rails 5 API + ActiveAdmin + create-react-app on Heroku
class ExampleController < ApiController
end
@superhighfives
superhighfives / api_controller.rb
Created March 4, 2017 13:05
Rails 5 API + ActiveAdmin + create-react-app on Heroku
class ApiController < ActionController::API
end
@superhighfives
superhighfives / index.js
Created March 3, 2017 21:52
Rails 5 API + ActiveAdmin + create-react-app on Heroku
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import 'semantic-ui-css/semantic.css'
import './index.css'
ReactDOM.render(
<App />,
document.getElementById('root')
)