Phase 2
Tags: ruby, sinatra, activerecord, project
Published: 2021-03-25 17:51:45

Today marks the 4th day into Project Week for Phase 2 at Flatiron's Software Engineering Bootcamp. 

Throughout the second phase, we were tasked with learning loads of new information. Of the many, we had learned both the basics & the depths of sql, active record, Sinatra, css, and html. This was definitely a step up from the last phase where we had learned strictly ruby object orientation principles. There were plenty of challenges for sure on my end but not without their eventual completion. 

The major challenge for this phase was learning how to implement CRUD and RESTful Routing. Basically what CRUD stands for is Create, Read, Update, and Delete and is used for persisting storage. If I were to plan out a website with a database that users can react with, I would implement CRUD to manipulate the data. Now as for the routes that allow users to access these CRUD methods is through RESTful routing. What it means to be RESTful is to follow the naming pattern of consistency across route name and paths that reflect what they are doing. 

Now, as a beginner, that is difficult to read in and of its own. Implementing this into a full on project is another story. But this is where the real fun is. For me, diving into this project was like diving into a pool without knowing HOW to swim. Sure I know the mechanics of swimming, and I've seen people swim before plenty of times. But as for the actual SWIMMING aspect, I'm dead weight. Same went for this project. Although it was a real struggle, removing the training wheels that come with labs is where I really cement the knowledge I've been collecting throughout the phase. 

To better demonstrate this, I'd like to show a little bit of my code. A feature I had wanted to implement is for user's to log in. To do this we start with a GET request to '/login' which will be in the form of a link on the home page. That looks a little like this:

```
 get '/login' do
        erb :'/users/login'
    end
```

Now, what this is doing is saying, hey, show me the login page which my program is designed to read this and provide the that login page through an erb file. Within that erb file I had to figure out how to display to the user sections for a user to input their credentials that is both productive and nice looking. In comes bootstrap. Bootstrap is basically a seamless way to add features to your website while doing all the work for you. This may sound lazy to some but an ocean of possibilities for beginners. Bootstrap not only allows you to get predesigned features but to manipulate your own. How I designed my login page is through the following:

```
 <div class="text-center">
    <form style="max-width:480px;margin:auto" action="/login" method="post">

        <img class="mt-4 mb-4" src="images/this.jpeg" height="100" alt="logo">
        <h1 class="h3 mb-3 font weight normal">Please sign in</h1>

    <input type="text" name="username" class="form-control" placeholder="Username" required autofocus>
    <input type="password" name="password" placeholder="Password" class="form-control">
    <div class="mt-3">
    <button class="btn btn-lg btn-secondary">Sign In</button>
    </div>
    </form>
    </div>
```

Which greatly benefits the user experience when put into action. From there the user's information is sent to the '/login' action through the method post which identifies the user and brings them to their profile page. Pretty cool, right? 

By the end of yesterday, which is when I had completed the first set of features I had hoped to create for this project, I can finally say I AM a Software Engineer. The fact that I was set out on my own and came back with a fully-functioning website, albeit still in its early stages, is indescribable. With 3 more phases to go, I am becoming more and more confident with my abilities to adapt to and implement any obstacle/knowledge that comes my way. 

Here's to another successful phase and to the ever-approaching finish line. Cheers.