This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IngredientsController < ApiController | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Drink < ApplicationRecord | |
has_many :ingredients | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |