Skip to content

Instantly share code, notes, and snippets.

@yosukehasumi
yosukehasumi / images.markdown
Last active April 2, 2019 22:02
Image Tutorial

Adding Images to your application

We are going to use the new and shiny ActiveStorage that is built into Rails 5! https://edgeguides.rubyonrails.org/active_storage_overview.html

We will add receipt images to transactions in our mint application. This way we can snap a photo of our receipt and attach it to our transaction.

Gemfile

Update your Gemfile by adding:

@yosukehasumi
yosukehasumi / lesson.markdown
Created March 26, 2019 18:47
Week 11 lesson

Lecture Notes

Helpers

View helpers are useful files that contain reusable code in an attempt to keep your views DRY and clean. They can be found in the /app/helpers directory. You can simply add methods here that you intend to reuse in your views.

Let's say you want to method to format a date object a specific way all the time (January 1, 2019). You could create a method here called mint_date(date) and place your logic inside. This method then can be used anywhere in any view.

In /app/helpers/application_helper.rb:

@yosukehasumi
yosukehasumi / assignment.markdown
Last active March 26, 2019 21:14
Assignment 9

Assignment 9

We are going to use Heroku to deploy our applications, to do this we are going to use git-style commands to automate our deployments.

Your assignment this week is to try and get your Mint application and your Final Project running on Heroku

First we need to create all the appropriate accounts and install all the necessary development tools

Prepping our Computers and Accounts

@yosukehasumi
yosukehasumi / rails-setup.markdown
Created March 20, 2019 17:00
Rails setup local

Install Homebrew (package manager)

https://docs.brew.sh/Installation

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install RBENV using Homebrew (ruby manager)

@yosukehasumi
yosukehasumi / heroku-deployment.markdown
Created March 19, 2019 19:08
Setting up for Heroku deployments

Setting up for Heroku deployments

  1. Create a heroku account https://signup.heroku.com/
  2. download heroku command line tools https://devcenter.heroku.com/articles/heroku-cli, I recommend that you install this on your computer and NOT in docker. (for OSX users you'll probably want to install Homebrew https://brew.sh/ and do the install using the brew commands so that you can do brew tap heroku/brew && brew install heroku)
  3. Log into heroku using your heroku-cli heroku login
@yosukehasumi
yosukehasumi / assignment.markdown
Last active March 19, 2019 21:12
Assignment 8

Rails Testing Intro

Rails comes packaged with a test suit that is ready to go and ready for you to build some helpful tests from the get-go! Let's learn how to use it.

Commands Cheat Sheet

When you want to run a whole test file

ruby -I lib:test PATH/TO/MY/FILE

@yosukehasumi
yosukehasumi / assignment.markdown
Last active March 5, 2019 23:44
img240 Week 7 Assignment

Assignment 7

Implementing clearance authentication

Adding Clearance gem

First thing we need to do is include Clearance into our applications Gemfile, have a look at https://github.com/thoughtbot/clearance for more information

  1. In our Gemfile add:
@yosukehasumi
yosukehasumi / seeds.rb
Created February 12, 2019 22:50
Better Mint Seed
Category.destroy_all
Category.create(name: 'Groceries', colour: '#0FB915')
Category.create(name: 'Gas', colour: '#B9AE0F')
Category.create(name: 'Takeout', colour: '#B9260F')
Category.create(name: 'Rent', colour: '#2D37BD')
Category.create(name: 'Pet', colour: '#882DBD')
Category.create(name: 'Car', colour: '#BD2DA0')
Category.create(name: 'Shopping', colour: '#4FBD2D')
Category.create(name: 'Work', colour: '#2DBD7A')
Category.create(name: 'Entertainment', colour: '#2DBDBD')
@yosukehasumi
yosukehasumi / assignment.markdown
Last active February 12, 2019 22:50
img240 Week 6 Assignment

Assignment 6

Okay today is cleanup day, we are going to get all the things we've been learning and put them together.

Also if you want a better seed file I've posted one here: https://gist.github.com/yosukehasumi/5a8329bce8f69915d8de41571b68b965

Routes

open up your routes.rb file and add root 'transactions#index' to the top to define the root of your application

Classes

  1. Create a file called quiz.rb with a class called Quiz
  2. Create an initialize method that takes no arguments, set an instance variable called @run to false

Methods

  1. Create a method called incrementer that accepts two arguments called array and increment
  2. Set the instance variable @run to true if the incrementer method is run