I Suddenly Know How It All Fits Together Better

lego stormrooper on a skateboard

I moved through a lot of curriculum today. However, I really want to hit the goal I set two weeks ago and I’m on the cusp of it! I had 21 lessons/labs to go for my goal when I checked early in the day. So I set a goal of 11 more today (I had already finished 2) and finish tomorrow. I missed it by one only because it’s late and I hit an hour and a half review lecture. Since I’m working on ActiveRecord sessions and authentication I want to pay better attention to this lecture than I usually do. Maybe even take a note or two :-).

Ealy in the day I got stuck on a nested forms lab. I was getting an error:

Failures:
  1) App POST /teams submits the form
     Failure/Error: click_button 'submit'
     TypeError:
       expected Hash (got String) for param `name'

but I couldn’t figure out why. My code was:

<h1>Create a Team and Heroes!</h1>
<form action="/teams" method="POST">
  <p>Team Name: <input type="text" name="team[name]"></p>
  <p>Team Motto: <input type="text" name="team[motto]"></p>
  <h2>Hero 1</h2>
  <p>Hero's Name: <input id="member1_name" type="text" name="team[name][hero][][name]"></p>
  <p>Hero's Power: <input id="member1_power" type="text" name="team[name][hero][][power]"></p>
  <p>Hero's Biography: <input id="member1_bio" type="text" name="team[name][hero][][bio]"></p>
  <h2>Hero 2</h2>
  <p>Hero's Name: <input id="member2_name" type="text" name="team[name][hero][][name]"></p>
  <p>Hero's Power: <input id="member2_power" type="text" name="team[name][hero][][power]"></p>
  <p>Hero's Biography: <input id="member2_bio" type="text" name="team[name][hero][][bio]"></p>
  <h2>Hero 3</h2>
  <p>Hero's Name: <input id="member3_name" type="text" name="team[name][hero][][name]"></p>
  <p>Hero's Power: <input id="member3_power" type="text" name="team[name][hero][][power]"></p>
  <p>Hero's Biography: <input id="member3_bio" type="text" name="team[name][hero][][bio]"></p>
  <button type="submit" value="submit">Submit</button>
</form>

I kept thinking, “How can form input be anything other than a String? Why is it expecting a hash?” I reached out to a Learn Expert (they’re like Teaching Assistants who are available almost 24/7 to help) and it took almost an hour to resolve it. However, figured out that because my third line had name="team[name] whenever I called a nested hash that contained team[name] it was returning the string I input instead of setting the params nested hash array to the proper thing. A quick change of my code to:

<h1>Create a Team and Heroes!</h1>
<form action="/teams" method="POST">
  <p>Team Name: <input type="text" name="team[name]"></p>
  <p>Team Motto: <input type="text" name="team[motto]"></p>
  <h2>Hero 1</h2>
  <p>Hero's Name: <input id="member1_name" type="text" name="team[hero][][name]"></p>
  <p>Hero's Power: <input id="member1_power" type="text" name="team[hero][][power]"></p>
  <p>Hero's Biography: <input id="member1_bio" type="text" name="team[hero][][bio]"></p>
  <h2>Hero 2</h2>
  <p>Hero's Name: <input id="member2_name" type="text" name="team[hero][][name]"></p>
  <p>Hero's Power: <input id="member2_power" type="text" name="team[hero][][power]"></p>
  <p>Hero's Biography: <input id="member2_bio" type="text" name="team[hero][][bio]"></p>
  <h2>Hero 3</h2>
  <p>Hero's Name: <input id="member3_name" type="text" name="team[hero][][name]"></p>
  <p>Hero's Power: <input id="member3_power" type="text" name="team[hero][][power]"></p>
  <p>Hero's Biography: <input id="member3_bio" type="text" name="team[hero][][bio]"></p>
  <button type="submit" value="submit">Submit</button>
</form>

and my tests were all passing.

I also realized today that I’ve been achieving the end goal of clearing out hashes without using the method provided by Ruby. When I read:

Luckily for us, there is already a Ruby method for emptying a hash: #clear.

I thought to myself, “Whoops!” because I’ve just been resetting hashes & arrays by doing @session = {} or @@all = [] up until this point. I haven’t checked the docs yet to make sure this method applies to arrays as well but I feel like I’ve seen it used so I’m relatively confident in that. I guess I’ll find out the first time I use it.

Time spent today: 6:37
Time spent total: 165:06
Lessons completed today: 12
Lessons completed total: 392

Do recruiters make you mad? What’s your advice?

So nested forms aren’t as bad as I thought they would be. I guess it helps that I had some good teaching before I got into it. I think I had the longest video yet to watch tonight and that took up most of the time once I finished the lab I started last night. The lab I’m on seems to be more of the same just getting the concept to stick with a more in-depth nested form. It has an option to persist the data AFTER getting the tests to pass initially. I’m not sure if I’ll attempt it or not. I know I’ll need to know the skill but does it help me more to struggle now and be a little quicker later? Or just struggle later one time? I know doing it more is definitely better but there are concessions I make in the interest of time.

Learned a good workflow for building an MVC app that uses a database. First start with the DB, then work on models, then controller routes, and finally the views. I had thought working in the other direction would make more sense but I’ll try what the lecture taught. My thinking is, I start with a view so I know what I’m trying to display, I’ll have my endpoint even if it doesn’t work. Then I’ll build the route that will fill in that view. Then I’ll build the model for the controller to use. Then build the database knowing the full amount of things I’ll need. This is how I thought I did the CLI Gem project where I started with the lowest level and worked my way out with stubbed data to get a final point where when I had real data it just worked. This might not be the best workflow when dealing with things like databases and controllers though. There might be things outside of my control that could end up creating a whole rewrite which would be very sad.

I put in a resume for a Jr. Dev (or was it Jr. Analyst?) role today and the recruiter called me back. To my surprise saying they work with a few companies that take boot camp grads. The main thing I was told is to finish and get that official certification or diploma saying I finished then we could talk. It’s nice to already be connected with someone even if it turns out to be nothing. While I’ve worked with recruiters in the past and never received an offer through any assistance they’ve given I think any interview is a good one for me moving into a new field. The questions and format will be something completely different from what I’m used to. As much as we all wish interviews could be nailed by the best candidate every time they just aren’t and interviewing is a skill in and of itself. I’m interested if there are any others out there that have used recruiters to land Junior level positions and what they thought about the process in hindsight?

Time spent today: 2:44
Time spent total: 158:29
Lessons completed today: 2
Lessons completed total: 380

How to Take it Easy Sometimes and Still Win

I only got a little bit of coding done tonight by choice. I think I’m procrastinating on this nested hash forms lab because nested hashes can get confusing. I started it though and just got sidetracked. I need to stay focused. I worked on getting RubyMine installed to see what it’s about and my computer froze. After that, I just gave up on coding tonight. I guess I wasn’t very motivated if that’s all it took lol.

However, I went to a good Ruby meetup tonight and got home late and am just distracted. I went to the Nash.rb 2nd Quarter Social tonight and hung out with people that are in the Ruby community here in Nashville. It was laid back and I just spoke with a bunch of people. A guy named Sam who just moved to Nashville last month and has 3 years of Rails experience yet went to Law school. Chris who graduated from The Iron Yard‘s Front End program in December and is just interested in Ruby. Pete who’s a VP at Takl who are looking for a Senior RoR’s dev. Jon and Jim who are both 10+ year devs who talked about their company but never named it. I was able to look at the Meetup RSVP list and then check LinkedIn to see they work for Groups360. Their company interested me because they’re looking to provide a SaaS product to the hospitality industry. Ty who works for Kindful and is somewhat jealous that he had to get a CS degree (75% of which was useless he said) because boot camps didn’t exist when he started. I don’t know if it’s the nootropics I’m taking or if I consciously made sure of it but I remembered every person’s name I met tonight and was able to say goodnight to them by name as well. This typically doesn’t happen.

I found this meetup to be much more interesting to me than the previous ones I have attended. I think it’s because we were interacting well and I was able to speak with all different levels of people. I’ve found there is A LOT of JavaScript around, and for good reason, so it as nice to speak to people who knew the things I’m currently learning. I’m looking forward to the Nash.rb meetups in the future. I’m sure I’ll get back to enjoying JS meetups as well as soon as I get to the JS curriculum and get back to that.

Time spent today: 0:33
Time spent total: 155:45
Lessons completed today: 0
Lessons completed total: 378

Sinatra, models, views, controllers, and erb, OH MY!

yield sign

Sinatra, and models, and views, and controllers, and erb, OH MY! Tonight I kept building small things with Sinatra. I’ve realized exactly how the MVC system works and what each piece does. The model is all the ruby classes I’ve been writing. The view is a mixture of HTML and Ruby that the user sees in their browser. The controller takes the user input and returns the data that has been crunched by the models. Now that I’m creating the route to a URL, creating the form on that page, sending the data that’s input back to the controller, having it sent to a model, having the model return it to the controller, having the controller retrieve a new view and send it to the user, it all makes way more sense. LOL.

One thing I think will be a big piece but was only touched on for a moment was yielding.

Let’s say we have a controller action:

get '/' do
 erb :index
end

When the above controller action is triggered and the erb method is called, it looks to see if there is a view titled layout.erb. If that file exists, it loads that content around the desired erb file, in this case index.erb.

The way the layout.erb will “wrap” the index.erb with its code when a <%= yield %> is inserted seemed like something important. Yet, I have yet to use it and I’m more than a few lessons past the readme that showcased it. Oh well, that’s one of the reasons I write about things here. So when I need to find it I know where to look.

Time spent today: 2:17
Time spent total: 155:13
Lessons completed today: 6
Lessons completed total: 378

Sinatra is Moving Along

fire and smoke

Sinatra is moving along and clicking well. I have this fear after being somewhat cocky in last night’s post that the spirits of those Senior Devs before me are going to jump into my learning and humble me some. If so, not today. It’s all making sense the first time through. I think this is because there’s very little new logic. It’s just where to put that login in regards to models, views, and controllers. Like, if I’m going to use ruby in a web page the page with be index.erb so it can be interpreted and I’ll have to wrap code in <% %> or <%= %> depending on what I’m going to do with it.

The largest piece of info I learned outside of more of the Sinatra DSL is how params work.

If you are unfamiliar with the params object and how it relates to form and inputs, that’s totally fine. The TL;DR is that all the information the user submitted in the form is available to your code within a hash named params.

So for form data, for example, let’s say we have <input name="username" value="" /> and the form has an input box and in that box is withloudhands (I don’t know why the curriculum chose this as an example lol). withloudhands is now the “current value”. Let’s say there’s also an email input which I won’t paint the picture of. The params hash after this is submitted would be {username:"withloudhands", email:"[email protected]"} and this hash can be used just like any other hash. So params[:username] would return "withloudhands". I did notice that the hash stores everything as strings so when performing math operations I had to utilize the .to_i method.

I also learned that controller actions never care about their return values. This came up when a student suggested using #tap in a lecture and Avi said that while it would work he didn’t think it was the best option. I still haven’t dived into what #tap actually does even though I’ve discussed it with Mike in the past. I did come across a great, and quick read, blog post “Block, yield, tap” by the more studious Rachel Walwood who’s also going through Flatiron right now. She goes through exactly what it is in a solid and concise manner.

Time spent today: 2:19
Time spent total: 152:56
Lessons completed today: 7
Lessons completed total: 372

The Standard Pace is for Chumps…

brain

I got a late start tonight 🙁 so I didn’t spend as much time as I would’ve liked. However, I did learn that my wife did not know that it was not a good idea to try and peel a cantaloupe with a chef’s knife. Yeah, so after helping her wrap a sliced finger in a paper towel cantaloupe slicing duty fell on me. Then I spilled my tea all over my desk because one of my children (I’m guessing the 2-year-old) had wedged my chair under my desk. When I pulled it out it shook the desk and *splash* everything went. My scroll wheel on my mouse is just now starting to work properly again.

I’m working through Sinatra now and nothing has been too confusing. It all seems pretty straightforward so far. Obviously, the more complex a web app gets the more confusing things will be. I’m interested to see if we’ll be building anything that integrates a database or not. I’ll find out in time. I’m going to attempt to build out a table with the notes I took on the Model View Controller (MVC) architecture a lot of apps are built on.

Model View Controller
Logic Front-End Middleman
Brains HTML
CSS
Forms
ERB*
Chef Guest Waiter

*ERB stands for Embedded Ruby

I think the thing that helped my grasping of the MVC the most was the restaurant analogy. The user interacts with the View which in turn interacts with the Controller which talks to the Model and returns back to the View with what the Model sends. So the Guest orders something and the Waiter takes that info to the Chef who then makes the food and sends the waiter back to the Guest with ti.

Two random things to mention:
1. Check out Informed Delivery from the USPS. I thought it was super cool then I realized you couldn’t tell the USPS to not deliver junk so the service seems literally useless.
2. Read There’s no speed limit. (The lessons that changed my life.) by Derek Sivers. If you have time listen to him on The Tim Ferriss Show as well.

The line “the standard pace is for chumps” (from the Sivers article) has always resonated. While I don’t think I’ve always worked hard enough to prove that true I know I’ve seen it. I think about my expectations going into this boot camp and how long I want it to take. Oh, 800+ hours you say? It’ll take months you say? Gimme 16 weeks from the first day to hired. You obviously don’t know me or that I’ve already completed a Masters degree 100% online or that I have a near-genius IQ or that I have a bunch of biohacks I’m using to crush it.

I’m going to be very interested to see how many hours I’ve put in when I complete Rails as that is approximately 75% of the way through the curriculum. Accordingly, it should be about 600 hours of work done at that point.

Time spent today: 2:01
Time spent total: 150:37
Lessons completed today: 10
Lessons completed total: 365

Day 35

networks

Progress progress progress. I’m moving along. I watched the last ActiveRecord video then finished up the Rack section. Learning the lowest level of how Rails runs a web server. There is a granular procedure that’s happening and it was explained. First, we learn basic Rack, then Sinatra abstracts a little bit more, then Rails abstracts even more. So when things do break, because they will, there is an understanding of what’s actually going on to fix it. This is the exact thing that I hear a lot of people complain about. They buy courses on Udemy or wherever and at the end of the course they have a working app that they can show off, BUT, they can’t explain why or how it works. I’ve fallen into that category in the past. It makes a lot of sense too. If you want to market something you have your students make fast progress and put the impetuous on them to do deeper learning. Like, do people really want to know how rack works? No. They just want it to work and use Rails because that’s easier. I guess that’s what separates those who end up being successful and those who fall to the side self-teaching.

I started this post before finishing my learning for the day. I think this sums it up well:

WHY SINATRA BEFORE RAILS

We’ve all heard of “Ruby on Rails” and how powerful it is. You can build impressive web applications in mere hours! How amazing. Most people, when they learn Rails for the first time, literally say “It’s like magic!”. But we’re developers, and we know that magic isn’t real and that other smart developers just built an impressive framework.

That means it’s important to understand the basic concepts of Rails before diving into Rails itself. Enter Sinatra.

Sinatra is considered a light weight framework where the responsibility of app structure and communication falls solely on the developer. Sinatra doesn’t give you a lot to get started with. There is no way to auto-generate files and directories, no way for the app to make assumptions about routes, or “Sinatra magic”.

Because of this, working with Sinatra allows you to dive in deep with the major concepts of MVC, a system for building web applications that govern 90% of the worlds’ apps. You are required to manually set up routes and connect them to other pieces of your application. Without this manual setup, your application does not automatically know how to communicate with your database or what HTML files to load in the browser. And even more importantly, without a manual setup, you lose connection to the major components of a web application, and in particular, all the moving pieces of MVC.

So introduce yourself to Sinatra. Get to know it, and know it well. The better your foundation, the more you’ll be able to know (and like) Rails.

A few other things that I picked up today. First, is that there are a bunch of other lorem ipsum word blocks out there and they’re typically pretty funny. There are some good ones in this SitePoint article. The one that Avi used is called Hipster Ipsum and made the people watching the lecture at the time ask about it.

Avi went on a tangent about how he thinks about how his life actually impacts others. How the web is this amazing thing that connects people and not just computers. How the time we’re in right now is crazy exciting because we are now as humans more connected and thus are able to do greater things as a species. I honestly don’t remember word for word but that’s the gist of it. A quote that stuck out to me:

The Web does not connect machines, it connects people.
- Tim Berners-Lee

It’s so true when we think about the impact that web apps have on real people. While my code might ultimately be interpreted by machines we don’t build things for machines to use. We are building things to connect and solve real problems for people. When I built the Meetup CLI Gem that has the potential to solve someone’s problem and connect them to other people at a meetup group. It may seem like technology on the surface but in the end, it’s all about people.

Even doing minimal work today (time wise) due to a much-needed haircut and the wedding shower I went to with my wife at Arrington Vineyards, I’m right on track with my pace and have finished 48 lessons/labs since last week. 🙂

Time spent today: 3:33
Time spent total: 148:36
Lessons completed today: 16
Lessons completed total: 355