Name | Singular/Plural | Use |
---|---|---|
Controller | Plural | rails g controller Users index show |
Helper | Plural | rails g helper Users |
Mailer | Singular | rails g mailer UserMailer |
Migration | Plural | rails g migration AddEmailToUsers email:string |
Model | Singular | rails g model User name:string |
Observer | Singular | rails g observer User |
Resource | Plural* | resources :users, :only => [:index, :show] |
Scaffold | Singular | rails g scaffold User name:string |
FROM node:7.10-alpine | |
RUN mkdir -p /opt/app | |
WORKDIR /opt/app | |
COPY ./package.json /opt/app | |
RUN apk add --update --no-cache tini &&\ | |
apk add --virtual .build-dependencies make gcc g++ python &&\ | |
npm install --production &&\ |
# Question: | |
# Suppose you have an array of 99 numbers. | |
# The array contains the digits 1 to 100 with one digit missing. | |
# Write four different algorithms to compute the missing number. | |
# Two of these should optimize for low storage and two of these should optimize for fast processing. | |
# (Keep in mind, there are no duplicates and the array is not already sorted.) | |
####################################################### |
" Setup Vim Core | |
set number "Nomor Baris Statik | |
set relativenumber "Nomor Baris Dinamik | |
set nocompatible | |
set softtabstop=2 | |
set backspace=indent,eol,start | |
filetype plugin indent on | |
set laststatus=2 | |
set linespace=3 |
class Api::RegionsController < ApplicationController | |
def provinces | |
prompt = [ | |
{ | |
id: "", | |
name: core_model_lang("province") | |
} | |
] | |
@provinces = prompt + Province.all | |
render json: @provinces.to_json(only: [:id, :name]) |
# See how variables work, and a list of predefined ones: | |
# - https://docs.gitlab.com/ce/ci/variables/ | |
variables: | |
RAILS_IMAGE: registry.gitlab.com/bryanbraun/gridmaster.io/railsapp:$CI_COMMIT_SHA | |
NGINX_IMAGE: registry.gitlab.com/bryanbraun/gridmaster.io/nginx:$CI_COMMIT_SHA | |
DEPLOY_TAG: $CI_COMMIT_SHA | |
cache: | |
paths: | |
- vendor/ruby |
You probably don't want Google crawling your development staging app. Here's how to fix that.
$ mv public/robots.txt config/robots.production.txt
$ cp config/robots.production.txt config/robots.development.txt
Now edit config/routes.rb
to add a route for /robots.txt
, and add the controller code.
In this episode we're going to be adding realtime notifications into your app using ActionCable. We've talked about notifications a few times in the past and we used AJAX polling for that. 95% of the time, polling is the solution that would be recommended for it.
But if you're looking for a good introduction into ActionCable then this is a decent one because we're only really using it for one way from the server side to the client side.
So to get started we're starting with an app that has Bootstrap installed and then we created a Main controller with an index view which is where we will list our Notifications as for this example.
Before we generate our channels let's install a few things
I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api
Rails.application.routes.draw do
constraints subdomain: "api" do
scope module: "api" do