This file contains 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 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 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 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 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: 'admin@example.com', password: 'password', password_confirmation: 'password') | |
negroni = Drink.create( |
This file contains 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 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 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 |
This file contains 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
group :development do | |
gem 'listen', '~> 3.0.5' | |
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring | |
gem 'spring' | |
gem 'spring-watcher-listen', '~> 2.0.0' | |
gem 'foreman', '~> 0.82.0' | |
end |
This file contains 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
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 |