Nick Bucciarelli

Hacker, instructor, yadda yadda.

2014 in Review

| Comments

Sorry it’s been a while, folks. I am not good at keeping up with a blog.

2014 has been a whirlwind of a year. If I had told you what was being planned by the beginning of the year, you guys would have told me I was f*cking crazy with no way of completing that list. I told myself the same thing at the beginning of the year.

I wanted to make 2014 special.

  • Blog more
  • Get more involved in the community
  • Certain salary goals
  • Lose 40+ pounds and get fit
  • Get engaged
  • Lead by example

There were a lot of flaws in my life that needed to be fixed.

Blog more

First, let’s start with the negative. I fail at blogging often. Made a goal to blog at least once a week and failed miserably at doing so. Apologies! Let’s hope I can keep up this year.

Get more involved in the community

While I was learning, there was an inherant issue with my involvement in the community. There needed to be more of it. I’m not talking about going to every meetup under the sun, I wasn’t participating at all. Going to anything at all would be an improvement. To a certain extent, this was fulfilled. Once a month, I would go to a meetup of interest with no agenda in mind. Just there to hang out!

Certain salary goals

A resolution/todo list wouldn’t be complete without having some vain goals. Mine was to meet certain salary goals. Not only did I start a new job, I also pushed very hard on the consulting front to meet these expectations. It was extremely difficult and time consuming, but alas, they were met.

Get fit

Exercise

Truth.

Another goal that is on EVERYONE’s resolution list is to lose weight. My health was on the decline. Since moving to Charleston, I have been eating out entirely way too much and eating the wrong kinds of foods. It’s been a goal of mine for the past few years and it’s never been taken seriously. Until I stepped on the scale in early January, I didn’t think anything of it. When I DID step on the scale, however, it was not a pretty sight. Something had to change. If you’ve been following my blog, you know what’s going on here.

Results

Sick gains, yo.

Get engaged

This was my number one priority. I’ve been dating a beautiful woman who deserves better then me. Getting engaged has been a long time coming. Frankly, it’s taken too long. She stuck around.

Engagement

She said yes! Wooo!

Lead by example

Part of my reasoning for taking the new job at The Iron Yard was to lead by example. It was nice absorbing all I could learn; but I had to give a bit back. Whether it was via teaching people programming or teaching people how to work out. I wanted to be a motivation for people to better themselves!

All in all, 2014 was a crazy ass year. If 2015 is anything like it, I’m in for a wild ride.

Lifehack: @@ and @@@ Shortcuts

| Comments

This is a major lifehack I’ve used the past few years that you all may want to consider, on your phones, make the following shortcuts:

  • @@
  • @@@

and make them display the following:

  • email
  • address

Frequently I have family members asking for my address, while others are texting me asking for my email.

Just a handy lifehack that I’ve used hundreds of times!

Progress Update - the Weeks I’ve Missed.

| Comments

Belt

My thumb is where I was at in January. I need to buy some new pants.

January: 220.0

(September) Week 1 – Day 1: 185.0

Week 1 – Day 1: 185.0

Week 2 – Day 8: 179.8

Week 3 – Day 15: 178.2

Week 4 – Day 22: 173.8

Week 5 – Day 29: 171.0

Week 6 – Day 36: 166.6

Week 7 – Day 43: 164.5

Week 8 – Day 50: 162.0

Week 9 – Day 57: 161.0 (Traveling, weighed in on day 54)

Current total transformation loss: 24.0

Current total loss: 59.0

Cassette Shirt

An Almost-Awesome Healthy Recipe

| Comments

Monday I got a craving for something sweet – PANCAKES – and I took it upon myself to figure out how to eat pancakes on this diet. I can’t eat dairy, soy, sugars, or saturated fats on this diet so that eliminates all of the ingredients to make pancakes. Arghhhh.

Ingredients:

  • Protein powder (I KNOW, WEIRD!)
  • Egg whites
  • Oats

The protein is a perfect substitute for the flour because it’s the same consistency and when you mix it into the egg whites, it makes a ‘batter’. Granted, the pancakes aren’t as good as normal ones, but they’re a great substitute if you can’t eat the former.

  • 1 scoop of protein powder
  • ½-2/3 cup of egg whites
  • ½-2/3 cup of raw oats

Mix them together and mix until consistent with pancake batter. If the batter you create is too thick, add some more eggs whites. If the batter is too watery, add some more protein.

Put a spoonful or two into a heated pan (with 0 calorie/fat/sugar no-stick spray), cook until it starts turning brown on the edges – AND YOU HAVE SOME PANCAKES. Mmmmm.

Next, the syrup. What is pancakes without some syrup?

(Walden Farms Syrup)[http://www.waldenfarms.com/products/syrup_pancake.html] tastes ALMOST like syrup. It’s close enough and is still really tasty.

Pancakes

Progress Update - Week 2 and 3

| Comments

Week 2 Weigh In

Here’s a picture of me dying. I have the coolest t-shirts.

I

Week 1 – Day 1: 185.0

Week 2 – Day 8: 179.8

Week 3 – Day 15: 178.2

Current total loss: 6.8

Last week, I did not lose much weight at all –1.6 pounds. Even though progress should not be as large as week 1, there still should have been more then that. There are several reason for this:

No week should have the same progress as week 1

My diet needs to change

I need to cut some of the carbs out of my diet. I’m consuming a lot more then I should. Instead of having 1 cup of pasta/rice, it’s being cut down to 2/3.

I had a cheat day (A day to eat myself silly!)

Ain’t she purty!? Me and Jenny

Jenny’s, Brian’s, and Shannon’s (Brian’s lady) birthdays are all in September, so we had a big birthday bash on Saturday. I ate myself silly. Hot dogs, burgers, doughnuts, cake – so much sugar I made myself sick. This was for a reason. Even though this cheat day was planned, I wanted to stop all of these cravings I was having, so I ate the foods my body was craving until I got sick. And that’s OK. Now, I ain’t cravin’ shit!

Cravings were not a huge problem the second week. I am on autopilot now.


Week 3 Weigh In

Week 1 – Day 1: 185.0

Week 2 – Day 8: 179.8

Week 3 – Day 15: 178.2

Week 4 – Day 22: 173.8

Current total loss: 11.2

HUGE week!! 4.4 pounds lost! Last week was ROUGH. My body is having trouble adjusting to the changes in diet and it’s not taking it well. Kris Gethin warned this would happen, but it’s hard to prepare for it. I’m extremely irritable and can’t focus as well as normal. The lack of fat sucks.

The irritability issues lasted a few days. No big deal. I’m still having issues focusing like I used to, but it’s getting better!

I also ran the “Run or Dye” 5k on September 20th! It was a ton of fun – everyone has bags of dye and runs a few miles while throwing the dye on other people. I was all kinds of green/yellow/purple/pink while going to the gym later for my 2nd cardio session.

Me and Brian posing at the start Me and Brian

I lost Brian. Where did Brian go?

My First VLog! Week 2 - Day 12

| Comments

Week 2 - Day 12

I am not a good writer, nor am I good in front of a camera. So why not practice both by blogging more, and vlogging more? Day 12 of my body transformation is a decent place to start, eh?

Week 1 in Review

| Comments

Hey guys, I’m back to review my first week on my new workout/diet regimen. First, the progress:

Started program: 185.0

Current weight: 179.8

5.2 lbs lost. Hell yeah! The first week is always the biggest week as far as weight loss is concerned because your body is expelling all of the sugars and bad nutrients it stored from before the changes. I was already getting pretty lean to begin with, so that is a big loss for me so far!

The first couple of days were extremely rough – getting used to the supplements and eating every 2-3 hours. I had to figure out a way to make the food not be so bland so I have been putting hot sauce on EVERYTHING.

My body is taking to it pretty well, though. I find myself more clear-headed and with more energy due to eliminating most all sugar.

Getting dommed(dominated) DOMS

DOMS, or delayed onset muscle soreness, is an acronym a lot of people use to describe the sore muscles 2 days after you work out. The day after workout isn’t usually too bad. The 2nd day after the workout is the worst. This is when your muscles turn really sore and you need to recover the muscles then most of all.

Motivation

Worst day

Even though every day is kicking my ass and pushing my body to it’s limits, the worst day was day 5 – shoulders, calves, and abs. The reason being is I haven’t worked my calf muscles out in a very long time. I still can not walk due to soreness and it’s been 3 days.

Favorite day

I really enjoyed yesterdays workout – Legs. We did some crazy high reps of a lot of weight to destroy your legs. Was a great and tiring workout.

http://www.bodybuilding.com/fun/kris-gethin-12-week-daily-trainer-week-1-day-7.html

Before legpress

Before 150 reps on legpress. (Don’t worry, I fixed my footing before I started!)

After legpress

After 150 reps on legpress.

My first eating out experience

Eating out when you are changing around your diet is a very difficult thing to do. We went to Moe’s and I sacrificed a lot of things I would previously have added to my burrito’s.

No dairy, soy, and as little sugar as possible. So, I had a whole grain tortilla, chicken, onions, cilantro, fresh jalapeno and that’s it. It was surprisingly good, though! I also had to cut the portions to be fist-sized. So I ate half of the burrito first, then the other half 2.5 hours later.

Tips

Get to sleep earlier

I have to start going to bed earlier. I go to bed around 11:30pm and wind up laying awake for a few hours before sleeping. I need to shut down the electronics earlier and get to bed earlier. This is a lifestyle change, not just a workout/diet regimen.

Fight the cravings

I’ve been pretty good about fighting the cravings so far. My advice is to fight through it. They will stop. After day 3, I haven’t really had a craving to eat anything crazy. I’m on autopilot now.

Surround yourself with good people

Surround yourself with people who motivate and inspire. Do not surround yourself with people who push you towards cheating. Just like in every aspect of life, if you surround yourself with people who support you, things will succeed so much more often.

Cheat Days

Cheat days are not advised. Once you fall back into 1 cheat day, it will turn into many. I have allotted myself 2 cheat days throughout the entirety of the program.

  • Jenny’s birthday is this weekend. I will be “cheating” on saturday by consuming some meats that are a bit more fatty then I would usually consume. Still no dairy, though. Lame. I miss cheese.
  • Thanksgiving. Turkey and corn. All I will eat, but I will consume a large quantity of said foods. Ain’t no diet getting in the way of my Thanksgiving.

Day 1

| Comments

Day 1 – Legs

Here we go.

Starting weight: 185.0lbs.

I have done the breakfast meals (egg whites and oats) and did the cardio already (20 minutes of running). I am sweating profusely because I decided to take my dog for a run. Apparently she is way out of shape. So we’re adding one more creature to the lifestyle mix: my dog. We ran 3.5 kilometers. She’s slowin’ me down!

Abby is tired.

I was supposed to take before pictures, but I forgot. I will take those as soon as I cool down.

After run

Building Better Habits.

| Comments

I have had the priveledge of being a part of a company that not only wants me to progress in my career, but personally as well. To do this, we put together 2 projects that do exactly that. 1 – do something, in short, that helps the company. 2 – do something that helps you personally. We are free to do whatever we want that falls within those broad scopes.

As some of you may know, Charleston can do quite a number to you. All of teh delicious food and bars makes for quite the unhealthy environment. I have regrettably gained a lot of weight since I have been here. I went from 170-180 pounds all of the way up to 220. I looked back at some of my habits and realized that I have become way to sedentary. Something needed to change. It was then that I went to the gym and got a personal trainer. He has since helped me lose 30 pounds and realize a love for exercising that I haven’t known before.

Before the weight loss:

Before the weight loss. Jenny looks beautiful, as always!

After the weight loss:

After the weight loss

Now, I am in better shape then I was in before (a WHOLE lot better), but there are still some goals that haven’t been met quite yet. I am plateuing in my training and need a change. Jermaine (my trainer) has worked wonders and helped me thus far. I am taking it upon myself to take it to the next level. With my personal project, I’ll be following a very regimented program – in both DIET and exercise.

Not only am I going to follow this regimen, two of my other friends are doing this with me. One to keep me accountable for every misstep and another to train and help better his habits as well.

DIET. MAN, DIET. I am not talking about eating salads every meal and cutting all kinds of calories. Your diet is what you eat on a day to day basis. My diet has been absolute shit and needs to change. The majority of body transformations aren’t from exercise, they’re from a strict diet of healthy foods. In short, we are eating infinitely healthier – less for enjoyment and more for health.

Exercise – I am still keeping to a very strict exercise routine, just changing how often I work out. 2 days on, 1 day off.

Kris Gethin – 12 Week Training

I am doing this routine and am going to love every minute of it.

Creating a Basic Rails Application

| Comments

I’m going to teach you how to create a basic rails application STEP BY STEP. There will be images and code for each step as well. I hope this works for you guys.

I know there are no tests written, but this is just for my students to create a ‘scaffold’ of controller/models.

There are a few dependencies as well:

  • rvm
  • Sublime text
  • Sublime text alias (sub) that will open your project folder

In this first step, I want to create myself a new project folder. I am going to call this project “contact_list” as that is what we will be creating together, a 21st century Rolodex!

1
2
3
% cd ~/projects/
% mkdir contact_list
% cd contact_list

This next will will set up dependencies. Anyone who has been in a ruby project for long enough will know that RVM is huge. We will be using that in this project. To make gemset management easier, we will be creating a “.rvmrc” file.

1
2
% touch .rvmrc
% sub .

Inside of that “.rvmrc” file, we need to create our specific gemset. This command will force your computer to create the gemset if you haven’t yet.

1
rvm 2.1@contact_list --create

This command should reload your current directory. The following screenshot will display what output you SHOULD get. If you do not get it, you need to cd out of your directory, then CD back in.

1
% cd .

Screenshot of stuff

Now, we are going to create our Rails project. To start, we need to install our Rails gem. After our gem is installed, we create a new project inside of our current directory with ‘rails new .’.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
% gem install rails
% rails new .

       exist
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/assets/images/.keep
      create  app/mailers/.keep
      create  app/models/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/secrets.yml
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/cookies_serializer.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/robots.txt
      create  test/fixtures
      create  test/fixtures/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.keep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.keep
         run  bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Installing rake 10.3.0
Using i18n 0.6.9
Using json 1.8.1
Using minitest 5.3.3
Using thread_safe 0.3.3
Using tzinfo 1.1.0
Using activesupport 4.1.0
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.0
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.0
Using mime-types 1.25.1
Using polyglot 0.3.4
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.0
Using activemodel 4.1.0
Using arel 5.0.1.20140414130214
Using activerecord 4.1.0
Using bundler 1.6.1
Installing coffee-script-source 1.7.0
Installing execjs 2.0.2
Installing coffee-script 2.2.0
Using thor 0.19.1
Using railties 4.1.0
Installing coffee-rails 4.0.1
Using hike 1.2.3
Using multi_json 1.9.2
Installing jbuilder 2.0.6
Installing jquery-rails 3.1.0
Using tilt 1.4.1
Installing sprockets 2.11.0
Using sprockets-rails 2.1.3
Using rails 4.1.0
Installing rdoc 4.1.1
Installing sass 3.2.19
Installing sass-rails 4.0.3
Installing sdoc 0.4.0
Installing spring 1.1.2
Installing sqlite3 1.3.9
Installing turbolinks 2.2.2
Installing uglifier 2.5.0
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
         run  bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted

Now, we’re going to start our server to make sure everything is kosher. Let’s start it and check it out!

1
% rails server

We have a rails project. This is the screen you guys should be getting. This is the “Welcome Aboard” message you get when you start every project.

Screenshot of stuff

I want to get rid of the “Welcome Aboard” screen and start developing my own application, so I need to go into “config/routes.rb” and set up a root route. This will be where my application starts. For instance, if someone comes to my application at “www.nickscontactlist.com”, this root route will be how it starts. The following code is telling it to go to a “Home” Controller’s “Index” action.

1
2
3
Rails.application.routes.draw do
  root 'home#index'
end

After this, I refresh my page to see what it tells me. Remember, you need to code a little then test the output.

Screenshot of stuff

Awesome! This is the error I wanted. I need to initialize a Home Controller now! Remember, Controller’s are generally pluralized! This one will be different. This is my landing page, hence “Home”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
rails generate controller home

      create  app/controllers/home_controller.rb
      invoke  erb
      create    app/views/home
      invoke  test_unit
      create    test/controllers/home_controller_test.rb
      invoke  helper
      create    app/helpers/home_helper.rb
      invoke    test_unit
      create      test/helpers/home_helper_test.rb
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/home.js.coffee
      invoke    scss
      create      app/assets/stylesheets/home.css.scss

Awesome. I have my Home controller created. Let’s refresh the page and see what happens.

Screenshot of stuff

This is a new error. I need to go into my newly created Home Controller to create my “index” action now.

1
2
3
4
class HomeController < ApplicationController
  def index
  end
end

Let’s refresh the page and see what happens.

Screenshot of stuff

I now need to create an index template. The template name matches the action name. Notice I am using the application to drive how I create things. Way cool.

1
touch app/views/home/index.html.erb

Let’s put something inside of the file as well.

1
<h1>Yey</h1>

Cool! Now, let’s create some more routes so I can do more things.

1
2
3
4
5
Rails.application.routes.draw do
  root 'home#index'

  resources :contacts
end

Let’s look at all of the routes I just created.

1
2
3
4
5
6
7
8
9
10
11
12
% rake routes

      Prefix Verb   URI Pattern                  Controller#Action
        root GET    /                            home#index
    contacts GET    /contacts(.:format)          contacts#index
             POST   /contacts(.:format)          contacts#create
 new_contact GET    /contacts/new(.:format)      contacts#new
edit_contact GET    /contacts/:id/edit(.:format) contacts#edit
     contact GET    /contacts/:id(.:format)      contacts#show
             PATCH  /contacts/:id(.:format)      contacts#update
             PUT    /contacts/:id(.:format)      contacts#update
             DELETE /contacts/:id(.:format)      contacts#destro

Let’s throw some more content in index.html.erb. I want to be able to create new data now, so let’s throw a “New Contact” link in there as well.

1
2
3
  <h1>Yey</h1>

  <%= link_to "New Contact", new_contact_path %>

Let’s refresh the page and see what happens. Let’s ALSO click the “New Contact” link.

Screenshot of stuff

Uh oh! I need to create a Contacts Controller now.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
rails generate controller contacts

      create  app/controllers/contacts_controller.rb
      invoke  erb
      create    app/views/contacts
      invoke  test_unit
      create    test/controllers/contacts_controller_test.rb
      invoke  helper
      create    app/helpers/contacts_helper.rb
      invoke    test_unit
      create      test/helpers/contacts_helper_test.rb
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/contacts.js.coffee
      invoke    scss
      create      app/assets/stylesheets/contacts.css.scss

Let’s refresh the page.

Screenshot of stuff

My controller is created, now I need to create the new actions.

1
2
3
4
class ContactsController < ApplicationController
  def new
  end
end

Cool, let’s refresh the page.

Screenshot of stuff

Now, I need to create a template to match my action name.

1
% touch app/views/contacts/new.html.erb

Refresh the page and look at a blank screen! Now let’s put some stuff inside of it.

1
2
3
4
5
6
7
8
<h1>New Contact</h1>

<%= form_for @contact do |f| %>
  <%= f.label :name %>
  <%= f.text_field :name %>
  <br>
  <%= f.submit %>
<% end %>

I want to create a new contact, so I put a form in there. Let’s fresh the page and see what happens.

Screenshot of stuff

I need to then go create some data to give to my form. I do that inside of the Controller. Let’s do that!

1
2
3
4
5
class ContactsController < ApplicationController
  def new
    @contact = Contact.new
  end
end

Awesome, data is created, let’s refresh and see what happens.

Screenshot of stuff

Oh no! I am missing my Model! Let’s create one.

1
2
3
4
5
6
7
% rails generate model contact
      invoke  active_record
      create    db/migrate/20140416191313_create_contacts.rb
      create    app/models/contact.rb
      invoke    test_unit
      create      test/models/contact_test.rb
      create      test/fixtures/contacts.yml

Refresh the page and let’s see what happens.

Screenshot of stuff

Oh, I created a Model and I forgot to add data to it so it’s telling me to migrate. Let’s go fill in the migration.

1
2
3
4
5
6
7
8
class CreateContacts < ActiveRecord::Migration
  def change
    create_table :contacts do |t|
      t.string :name
      t.timestamps
    end
  end
end

Now, let’s run the migration.

1
2
3
4
5
6
% rake db:migrate

== 20140416191313 CreateContacts: migrating ===================================
-- create_table(:contacts)
   -> 0.0014s
== 20140416191313 CreateContacts: migrated (0.0015s) ==========================

Wooo! Got some data fields. Let’s fresh the page now:

Screenshot of stuff

Hell yeah. Let’s fill in the form and click “Create Contact”.

Screenshot of stuff

Oh no! Let’s go create a “new” action inside of our Contacts Controller.

1
2
3
4
5
6
7
8
9
class ContactsController < ApplicationController
  def new
    @contact = Contact.new
  end

  def create
    @contact = Contact.create params[:contact]
  end
end

Cool. Let’s go back to the form and fill it out again. Click “Create Contact”.

Screenshot of stuff

Oooo. This is a new Rails thing. We need to add a method that whitelists parameters inside of our controller. We do it like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class ContactsController < ApplicationController
  def new
    @contact = Contact.new
  end

  def create
    @contact = Contact.create que_params
  end

private
  def que_params
    params.require(:contact).permit(:name)
  end
end

Let’s try to submit again.

Screenshot of stuff

Now, I need to either tell my action to render something, or I need to redirect. Let’s redirect to our root page.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class ContactsController < ApplicationController
  def new
    @contact = Contact.new
  end

  def create
    @contact = Contact.create que_params
    redirect_to root_path
  end

private
  def que_params
    params.require(:contact).permit(:name)
  end
end

Refresh and fill out the form again.

Screenshot of stuff

It redirected correctly, but no data is showing up. Let’s render out some data to the user.

1
2
3
4
5
6
7
8
<h1>Yey</h1>

<%= link_to "New Contact", new_contact_path %>
<br>
<% @contacts.each do |contact| %>
  <%= contact.name %>
  <br>
<% end %>

Let’s refresh the page.

Screenshot of stuff

I forgot to define my @contacts variable! Let’s go do that inside of the Home controller.

1
2
3
4
5
class HomeController < ApplicationController
  def index
    @contacts = Contact.all
  end
end

Let’s see what happens when I refresh.

Screenshot of stuff

Oooo data. Let’s see what I want to do next:

1
2
3
4
5
6
7
8
9
10
11
12
% rake routes

      Prefix Verb   URI Pattern                  Controller#Action
        root GET    /                            home#index
    contacts GET    /contacts(.:format)          contacts#index
             POST   /contacts(.:format)          contacts#create
 new_contact GET    /contacts/new(.:format)      contacts#new
edit_contact GET    /contacts/:id/edit(.:format) contacts#edit
     contact GET    /contacts/:id(.:format)      contacts#show
             PATCH  /contacts/:id(.:format)      contacts#update
             PUT    /contacts/:id(.:format)      contacts#update
             DELETE /contacts/:id(.:format)      contacts#destro

Let’s make an “Edit” link next for each contact with the route we found above.

1
2
3
4
5
6
7
8
9
<h1>Yey</h1>

<%= link_to "New Contact", new_contact_path %>
<br>
<% @contacts.each do |contact| %>
  <%= contact.name %>
  <%= link_to "Edit", edit_contact_path(contact) %>
  <br>
<% end %>

Let’s refresh and click it.

Screenshot of stuff

Cool. Let’s go create that action.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class ContactsController < ApplicationController
  def new
    @contact = Contact.new
  end

  def create
    @contact = Contact.create que_params
    redirect_to root_path
  end

  def edit
  end

private
  def que_params
    params.require(:contact).permit(:name)
  end
end

Let’s refresh and click the “Edit” link again.

Screenshot of stuff

Let’s create our “Edit” template now.

1
% touch app/views/contacts/edit.html.erb

And let’s populate it with something.

+ erb
1
<h1>Edit Contact</h1>

Refresh the page.

Screenshot of stuff

Woo woo! Let’s put a form in there to edit some data.

1
2
3
4
5
6
7
8
<h1>Edit Contact</h1>

<%= form_for @contact do |f| %>
  <%= f.label :name %>
  <%= f.text_field :name %>
  <br>
  <%= f.submit %>
<% end %>

Refresh and see what happens.

Screenshot of stuff

Now I need to go into my Controller and make that variable.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class ContactsController < ApplicationController
  def new
    @contact = Contact.new
  end

  def create
    @contact = Contact.create que_params
    redirect_to root_path
  end

  def edit
    @contact = Contact.find params[:id]
  end

private
  def que_params
    params.require(:contact).permit(:name)
  end
end

Refresh and see what happens.

Screenshot of stuff

Let’s fill in some data and click the “Update Contact” button.

Screenshot of stuff

Cool! Let’s go put that update action in there.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class ContactsController < ApplicationController

  def new
    @contact = Contact.new
  end

  def create
    @contact = Contact.create que_params
    redirect_to root_path
  end

  def edit
    @contact = Contact.find params[:id]
  end

  def update
    @contact = Contact.find params[:id]
    @contact.update_attributes que_params
    redirect_to root_path
  end

private
  def que_params
    params.require(:contact).permit(:name)
  end
end

And submit the data again.

Screenshot of stuff

Woo woo! Let’s see what route we want to do next

1
2
3
4
5
6
7
8
9
10
11
12
% rake routes

      Prefix Verb   URI Pattern                  Controller#Action
        root GET    /                            home#index
    contacts GET    /contacts(.:format)          contacts#index
             POST   /contacts(.:format)          contacts#create
 new_contact GET    /contacts/new(.:format)      contacts#new
edit_contact GET    /contacts/:id/edit(.:format) contacts#edit
     contact GET    /contacts/:id(.:format)      contacts#show
             PATCH  /contacts/:id(.:format)      contacts#update
             PUT    /contacts/:id(.:format)      contacts#update
             DELETE /contacts/:id(.:format)      contacts#destro

Let’s have a link that shows each individual contact now:

1
2
3
4
5
6
7
8
9
<h1>Yey</h1>

<%= link_to "New Contact", new_contact_path %>
<br>
<% @contacts.each do |contact| %>
  <%= link_to contact.name, contact_path(contact) %>
  <%= link_to "Edit", edit_contact_path(contact) %>
  <br>
<% end %>

Let’s click our newly created links.

Screenshot of stuff

Cool. Let’s create the show action.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class ContactsController < ApplicationController
  def show
    @contact = Contact.find params[:id]
  end

  def new
    @contact = Contact.new
  end

  def create
    @contact = Contact.create que_params
    redirect_to root_path
  end

  def edit
    @contact = Contact.find params[:id]
  end

  def update
    @contact = Contact.find params[:id]
    @contact.update que_params
    redirect_to root_path
  end

private
  def que_params
    params.require(:contact).permit(:name)
  end
end

Refresh the page and see what happens.

Screenshot of stuff

Let’s go create our template.

1
touch app/views/contacts/show.html.erb

Throw some stuff in there.

1
2
3
4
5
<h1>Show data</h1>

<%= @contact.name %>

<%= link_to "Home", root_path %>

Let’s see what to do next!

1
2
3
4
5
6
7
8
9
10
11
12
% rake routes

      Prefix Verb   URI Pattern                  Controller#Action
        root GET    /                            home#index
    contacts GET    /contacts(.:format)          contacts#index
             POST   /contacts(.:format)          contacts#create
 new_contact GET    /contacts/new(.:format)      contacts#new
edit_contact GET    /contacts/:id/edit(.:format) contacts#edit
     contact GET    /contacts/:id(.:format)      contacts#show
             PATCH  /contacts/:id(.:format)      contacts#update
             PUT    /contacts/:id(.:format)      contacts#update
             DELETE /contacts/:id(.:format)      contacts#destro

Let’s make a delete link

1
2
3
4
5
6
7
8
9
10
<h1>Yey</h1>

<%= link_to "New Contact", new_contact_path %>
<br>
<% @contacts.each do |contact| %>
  <%= link_to contact.name, contact_path(contact) %>
  <%= link_to "Edit", edit_contact_path(contact) %>
  <%= link_to "Delete", contact_path(contact), method: :delete %>
  <br>
<% end %>

Let’s click the link and see what happens.

Screenshot of stuff

Let’s make a delete link!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class ContactsController < ApplicationController
  def show
    @contact = Contact.find params[:id]
  end

  def new
    @contact = Contact.new
  end

  def create
    @contact = Contact.create que_params
    redirect_to root_path
  end

  def edit
    @contact = Contact.find params[:id]
  end

  def update
    @contact = Contact.find params[:id]
    @contact.update_attributes que_params
    redirect_to root_path
  end

  def destroy
    @contact = Contact.find params[:id]
    @contact.delete
    redirect_to root_path
  end

private
  def que_params
    params.require(:contact).permit(:name)
  end
end

All dooooooonnnnnnnnneeee!

Screenshot of stuff