Skip to content

Instantly share code, notes, and snippets.

View superhighfives's full-sized avatar

Charlie Gleason superhighfives

View GitHub Profile
@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 / 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')
)
@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 / 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 / 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 / drink.rb
Created March 3, 2017 00:28
Rails 5 API + ActiveAdmin + create-react-app on Heroku
ActiveAdmin.register Drink do
permit_params :title, :description, :steps, :source
# 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 / seeds.rb
Created March 3, 2017 00:14
Rails 5 API + ActiveAdmin + create-react-app on Heroku
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
AdminUser.create!(email: '[email protected]', password: 'password', password_confirmation: 'password')
negroni = Drink.create(
@superhighfives
superhighfives / drink.rb
Created March 2, 2017 23:58
Rails 5 API + ActiveAdmin + create-react-app on Heroku
class Drink < ApplicationRecord
has_many :ingredients
end
@superhighfives
superhighfives / application.rb
Last active March 2, 2017 23:57
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 / error
Created March 2, 2017 18:40
Rails 5 API + ActiveAdmin + create-react-app on Heroku
$ bin/rails g scaffold drink
Running via Spring preloader in process 38277
Expected string default value for '--serializer'; got true (boolean)
invoke active_record
create db/migrate/20170302183027_create_drinks.rb
create app/models/drink.rb
invoke test_unit
create test/models/drink_test.rb
create test/fixtures/drinks.yml
invoke resource_route