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
[ | |
{ | |
"font_face" : "Menlo-Regular", | |
"color_scheme" : "Packages/Color Scheme - Default/Monokai.tmTheme", | |
"always_show_minimap_viewport" : false, | |
"auto_complete" : true, | |
"tab_completion" : true, | |
"trim_automatic_white_space" : true, | |
"tab_size" : 2, |
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 AddHstoreExtension < ActiveRecord::Migration[5.1] | |
def self.up | |
enable_extension "hstore" | |
end | |
def self.down | |
disable_extension "hstore" | |
end | |
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 CreateUsers < ActiveRecord::Migration[5.1] | |
def change | |
create_table :users do |t| | |
t.string :first_name | |
t.string :last_name | |
t.string :email | |
t.string :phone | |
t.hstore :address | |
t.string :eye_color |
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
def user_params | |
params.require(:user).permit(:first_name, :last_name, :email, :phone, :eye_color, :dob, address: [:street_address, :city, :state, :zip]) | |
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
<%=form_with(model: user, local: true, :html=> {class: 'ui form'}) do |form| %> | |
<% if user.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(users.errors.count, "error") %> prohibited this user from being saved:</h2> | |
<ul> | |
<% user.errors.full_messages.each do |message| %> | |
<li> | |
<%=message %> | |
</li> | |
<% 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
<script src="https://s3.amazonaws.com/stitch-sdks/js/library/stable/stitch.min.js"></script> |
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
const stitch = require("mongodb-stitch") | |
//'rating-iyxzl' is the app name given by stitch | |
const client = new stitch.StitchClient('rating-iyxzl'); | |
// the db name 'tour-of-heroes' was provided by me | |
const db = client.service('mongodb', 'mongodb-atlas').db('tour-of-heroes'); | |
client.login().then(() => | |
db.collection('ratings').updateOne({ owner_id: client.authedId() }, { $set: { number: 42 } }, { upsert: true }) | |
).then(() => | |
db.collection('ratings').find({ owner_id: client.authedId() }) | |
).then(docs => { |
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
# /config/prod.exs on Heroku | |
use Mix.Config | |
# Configure for SSL | |
config :app, AppWeb.Endpoint, | |
load_from_system_env: true, | |
url: [scheme: "https", host: "https://app.herokuapp.com", port: 443], | |
force_ssl: [rewrite_on: [:x_forwarded_proto]], | |
cache_static_manifest: "priv/static/cache_manifest.json", | |
secret_key_base: Map.fetch!(System.get_env(), "SECRET_KEY_BASE") |
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
# shortened for brevity | |
defp aliases do | |
[ | |
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], | |
"ecto.reset": ["ecto.drop", "ecto.setup"], | |
"test": ["ecto.create --quiet", "ecto.migrate", "test"], | |
"ecto.migrate": ["ecto.migrate", "ecto.dump"] | |
] | |
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
# step 0 | |
iex> "freddy" | |
"freddy" |
OlderNewer