<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Celeste on Medium]]></title>
        <description><![CDATA[Stories by Celeste on Medium]]></description>
        <link>https://medium.com/@dvlpher?source=rss-f5f7c3c16f0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uwATHEior-anw5YA5tjL9w.jpeg</url>
            <title>Stories by Celeste on Medium</title>
            <link>https://medium.com/@dvlpher?source=rss-f5f7c3c16f0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:01:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dvlpher/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Coding with ADHD]]></title>
            <link>https://dvlpher.medium.com/coding-with-adhd-8158e9bfaf6?source=rss-f5f7c3c16f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8158e9bfaf6</guid>
            <category><![CDATA[adhd]]></category>
            <dc:creator><![CDATA[Celeste]]></dc:creator>
            <pubDate>Tue, 07 Dec 2021 19:04:47 GMT</pubDate>
            <atom:updated>2021-12-07T19:04:47.478Z</atom:updated>
            <content:encoded><![CDATA[<p>In 2020, I revisited therapy. I had noticed that there were a few things that I was struggling with: time management, organization, and consistency to name a few. Like most I did a google search with all the things that I was experiencing and came to the conclusion that I wanted to be evaluated for ADHD(Attention Deficit Hyperactivity Disorder) — <strong>It is a medical condition. A person with ADHD has differences in brain development and brain activity that affect attention, the ability to sit still, and self-control. ADHD can affect a one at school, at work, at home, and in friendships or relationships. </strong>I started to do research on therapist that specifically work with ADHD and can diagnose it. Low and behold after my first session I was diagnosed. To be honest, it made a lot of sense, and originally I was disappointed because I found in high school, college and really my day to day life I struggled a lot with focus and I thought that I was a me thing vs I needed assistance.</p><p>One of the things that prompted me to look into a diagnosis was starting my Coding Bootcamp journey. I wanted to be as successful as possible. I already saw habits that showed in my life prior to the bootcamp starting to rear their head.</p><p>After the first few sessions my therapist and I came up with a plan. We introduced medicine at a low dosage to see if it would assist in any capacity. Immediately I saw a change. I was able to focus longer, engage more, actively listen(not just listen to respond) and sit in my meetings and overall just be more present. For me, sitting in a lecture I could focus for maybe 5 minutes then I was thinking about something else, doing something else, writing something else. Literally, filling my time with EVERYTHING but what I was suppose to be filling my time with and I couldn’t understand why. I was so interested in learning code it was such a deep desire and all along I just did not know that I needed assistance.</p><p>I do want to note that, what worked for me may not work for all. I can wholeheartedly say had I known of my diagnosis prior to starting my coding bootcamp, I would have opted in to the in person coding courses. I still would have done part-time as I do believe that learning at the full-time pace would have been overload for me. Over the past 10 months I have learned that I learn most efficient when I am in person, in real time.</p><p>Once I adjusted to the medication I found change in small things: being attentive was the major game changer. That in itself allowed me to sit through my entire lecture without venturing off into something else. Also my therapist and I created a game plan. One being lists. Because ADHD allowed me to veer off often, holding myself accountable with a list to remind me what it was I was suppose to be doing was extremely helpful. Additionally, my medication allowed me to slow down, in the past for example say my cohort lead said “Here we are going to make a pull request” — my mind would hear the word “pull” find an association to it, (often in a song) and then I would start singing in my head. Once diagnosed I could hear the sentence for all that it was. I will say medication is not an immediate fix, and it might not be right for you.</p><p>With just about anything there has to be action backed by the change. So for example though I had a diagnosis and medication to now assist me, I had to also still do the work to see the change. Showing up to class, taking notes, utilizing my support system, showing up to my therapy sessions and creating an action plan. I do not believe that I would have saw change had I only taken my medication. I do not believe that I would have been successful in my coding bootcamp.</p><p>I understand that I am fortunate enough to have access to healthcare. Had I not, I would still be looking for a diagnosis. If you do not have access, there are some therapists that offer sliding scales which are discounted sessions upon request. Additionally it may be worth checking with your state, or city to see if they have any free services that they offer. Lastly, you are your strongest advocate, I’ve read many stories on people who were not diagnosed until they requested multiple times that they be evaluated for ADHD. You know yourself the best, you know if something isn’t right. Trust that. Also, if you do have any questions, please don’t hesitate to message me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8158e9bfaf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to be more productive]]></title>
            <link>https://dvlpher.medium.com/how-to-be-more-productive-cd4692b660df?source=rss-f5f7c3c16f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd4692b660df</guid>
            <dc:creator><![CDATA[Celeste]]></dc:creator>
            <pubDate>Mon, 06 Dec 2021 19:00:02 GMT</pubDate>
            <atom:updated>2021-12-07T18:29:00.809Z</atom:updated>
            <content:encoded><![CDATA[<p>Throughout my journey at Flatiron I had one consistent takeaway after each module.</p><p>“Consistency = Success”</p><p>I saw the difference early. Scheduling out my week vs. “Winging it”. Here are a few things that assisted me and a few things that derailed me.</p><h3>- What Worked</h3><ol><li>Having a calendar: whether that’s handwritten, in an app, or the native mail app. I personally found that I was most successful when I used all three. Visibility seemed to work the best for me. When I only used a handwritten calendar it was easy to block it out. The following is what helped the most for me. On Sunday night write out my entire week Monday- Sunday, additionally I would enter that entire schedule into my phone mail app and set two reminders for each item. Being accountable is key. You have to follow the schedule or eventually you will be moving everything around with the hopes that you will get there. Discipline is necessary . Each day following I would create a daily list(#3).</li><li>Study Groups: I was fortunate to have people in my cohorts that wanted to learn just as much as I did. I found that simply talking about things out loud would give me so much clarity on topics.</li><li>Daily Lists: Each morning, I would wake up and write out my to-do’s for the day. This being said, I would check my calendar for what I wanted to accomplish. These things would go into my MUST DO tasks. I also had a “want to get to” section and then a “if finished with everything else”. This list allowed me to stay on task and also allowed me stay on time and check back on my list when I felt like I was getting off of task.</li><li>1 on 1 sessions: These sessions were so important to my learning, because though I do ask A LOT of questions in my group learning sessions, sometimes you can feel like you’re delaying some of your cohort mates. Having dedicated time to work solely on the issues you are having or the questions you have is so important and helpful. It also allowed me to get real time answers to issues I was experiencing. This also allowed me to dedicate time to my projects, my labs, and just overall questions that I had.</li><li>Dedicated study time: I tried to be as disciplined as possible in this area because I truly believe that though labs created real time execution, study concepts over and over again allowed it to actually sync with my brain. Studying also allowed space for more questions to come. I was able to see the difference in studying and not studying. I found that I was more efficient in my labs, they required less time, or less assistance when I studied versus when I did not.</li><li>Outside lab practice: I utilized codecademy a lot. Though I think it is important to note that some of what I learned through labs from Flatiron and some of what i saw through codecademy did not always align. BUT again, this created more questions, like “why this why instead of that way”, or “when would I utilize this way versus utilizing the other way?”, “is this worth learning?” and it allowed me to sculpt my craft a little more.</li><li>GOOGLE: When in doubt GOOGLE IT, and Google it again, and again, and again. Stack overflow, other medium posts. Sidenote: other medium posts are so helpful because you’ll sometimes find someone who started off with the same question as you and then they breakdown thoroughly how they found the solution. and then you study that until it makes sense and that returns you to asking questions.</li><li>live coding sessions with “Ask a question”</li></ol><h3>- What did not Work</h3><ol><li>Procrastination: When I put things off, that was detrimental to my learning, because sometimes “putting it off” lead to it not getting done. I needed to create discipline within myself or I would not be successful. I suggest finding an accountability partner if you struggle with procrastination. OR making weekly 1 on 1 meetings with your cohort lead a thing because that can create accountability in itself.</li><li>Not asking questions: When I did not ask questions I found that an issue that may have been resolved in one day took a week to resolve. I believe that not asking questions ties into feeling like you aren’t good enough, smart enough or that you don’t belong. You do. You would not have been accepted if you didn’t.</li><li>Trying to do it alone: Recently, I really came to the conclusion that most things in life are not meant to be done alone. Coding Bootcamp is one of those things, find your people whether that’s in your cohort, through the channels that you have access to in slack. Having a community is important.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd4692b660df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My React App]]></title>
            <link>https://dvlpher.medium.com/my-react-app-7352be563126?source=rss-f5f7c3c16f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/7352be563126</guid>
            <dc:creator><![CDATA[Celeste]]></dc:creator>
            <pubDate>Mon, 22 Nov 2021 15:27:59 GMT</pubDate>
            <atom:updated>2021-11-22T16:42:43.996Z</atom:updated>
            <content:encoded><![CDATA[<p>I decided to create an app that allows me to track my festivals. I found this app to be useful because(before covid) I was a frequent festival(er?). I started by creating my rails api for my backend. I started with the models User, Location, and Trip. I narrowed it down to user and trip for now as I determined this is a project I want to continue to work on and implement new things such as vendors, performers, hotels etc with the overall goal to create a life long festival tracker that one day I’ll be able to look back on and locate all the festivals I’ve attended, all the artists I’ve seen and maybe even have the functionality to upload photos.</p><p>I utilized jsonapi-serializer as my serializer for my api that allows me to filter through the data I want to send to my front end. For example for my user, they have password_digest, without my serializer I was sending all of the user data to my frontend including my password digest, with my serializer I am able to say, “I only want my front end to have access to these specific attributes”. Once I create all of my associations, models, controllers, and my serializers I had to configure my api to talk to my react app.</p><p>Once my backend was pretty much set up I had to configure my backend to talk to my frontend. In my gemfile I activated rack-cors which allows me to whitelist my frontend to allows incoming requests. There is an option to whitelist EVERY site, but for security purposes it’s best to whitelist specific links.</p><p>Next I started to build my react-app using create-react-app. First thing I did was update my app function to a class. I then imported thunk for redux which is “<strong>middleware that allows you to call the action creators</strong> that return a function(thunk) which takes the store’s dispatch method as the argument and which is afterwards used to dispatch the synchronous action after the API or side effects has been finished.”(Eternus Solutions). I also had to create my store. Next I created my first reducer, then I need to add that reducer to my combined reducers which is inside my store.js. My combinedReducer handles all the state of my store. This gives each reducer to my store through thunk. Once I created my store I needed to export it.</p><p>Next I needed to build an action and reducer to grab my currentUser. In my reducer I created the state of my currentUser. Inside of my currentuser action I created a setCurrentUser function which will take in a user as an object and return the action. Within the action the type needs to match the case in the reducer. My action creator received my user object as an argument, which then took the place of the second argument in my return action. my setCurrentUser action was a synchronous action. In synchronous operations tasks are performed one at a time and only when one is completed, the following is unblocked. In other words, you need to wait for a task to finish to move to the next one. In asynchronous operations, on the other hand, <strong>you can move to another task before the previous one finishes</strong>(Out Systems). Additionally synchronous returns a plain JS object and asynchronous allows the use of dispatch and returns a function expression.</p><p>In my backend I needed to create my sessions controller. I want to also note I namespaced my routes to be nested under api/v1/…. My Login function fetches from my route api/v1/login which is actually hitting the create method in my sessions controller. I needed to utilize a POST method because I am creating a session which takes from the backend. In this fetch request I utilize dispatch. Dispatch comes from redux and is a function invoked. To dispatch an action I first need to convert my response to json. Dispatch comes in as an argument meaning it is a function. In my function I use dispatch as such: dispatch(setCurrentUser(user). I pass in the user object, disptching the action of setCurrentUser, which hits my reducer currentUser and catches the case: SET_CURRENT_USER and then returns the entire user object. To connect this to my rails backend I need to create a method called get_current_user and also create the route within my backend. With that created within my App.js I need to create my function componentDidMount() which I call on this.props.getCurrentUser(). componentDidMount is a hook that gets invoked right after a React component has been mounted aka after the first render() lifecycle. A hook allows you to access state without using a class.</p><p>Next I needed to give my login state to Redux which meant I needed another action creator and reducer. which again means I needed to export my reducer and add it to my combined reducers in my store. I created my Login component which would utilize a form for a user to enter their username and password. In this component I utilized mapStateToProps, so I took the state of the form from redux. In order to utilize mapStateToProps I need to import connect. I have access to Connect through Thunk, additionally Thunk gives me dispatch. Connect accepts up to four different parameters. In my Login form: <strong>export default connect(mapStateToProps, { updateLoginForm, login })(Login)</strong> mapStateToProps which gives react the state of my redux, updateLoginForm which comes from action creator loginForm, and the login function that comes from my currentUser action creator. and then finally exporting the component Login. In my Login function I am able to utlize the props I grab from mapStateToProps and spread over them, and update directly within the handler. In my handleInputChange I use the same handler for both my username and password, so I use the event to dynamically grab the name and the value then send it to updateLoginForm. Within my Login function I use spread on my loginForm prop which basically says build me an object and update it with the values given. Spread allows it to keep the properties in place. For my form I used redux, in the event I would have used React, I would have to create a class component which holds the local state. Now in order to have sessions within my controller I must activate them. I had to do the following: turn cookies on, turn sessions on, tell my backend I am using sessions and cookies, and tell my frontend to send them with my fetch requests.</p><p>Inside my application.rb I added:</p><p>config.api_only = true</p><p>config.middleware.use ActionDispatch::Cookies</p><p>config.middleware.use ActionDispatch::Session::CookieStore, key: ‘_cookie_name’</p><p>Inside of my cors.rb file I had to add:</p><p>credentials: true</p><p>Now with that configured in my fetch requests I have to “include” my credentials.</p><p>After I created all the functionality for my login, I wanted to reset the state of my login form, meaning when the user logged in after they log out and go back to login they don’t see what the last login info was. To do that I created a reducer case in my loginForm.js reducer and then the action creator, I needed to import the action into my login function in order to call dispatch(resetLoginForm()).</p><p>Once I created my login functionality, I had to create my logout functionality, which was fairly similar. I needed a destroy method in my sessions controller, and a route. Then to link it to my frontend I needed a Logout component. Since I have a currentUser reducer, I just added another case statement to it. I think added another asynchronous action creator. Within my logout action, I needed to destroy the session but also clear the state of my currentUser. sessions.destroy was an easy implementation for my backend which in theory would mean once the session is destroyed there is no logged in user meaning they wouldn’t be able to access anything. But react believes there is still a logged in user and to clear that I created a reducer case statement called clearCurrentUser and an action that follows. To verify this works I utilized my developer tools, checked the state in redux, and then checked for a successful delete request in my network tools. When I click the logout button, the action creator “logout” gets dispatched by redux, because I have “thunk” it then returns a fuction which stats on the first line within the logout function in my actions/currentUser.js. The function gets dispatched as an arguemnt, I then clear the current user, then it returns a fetch request which tells the backend to clear the session.</p><p>Next I wanted to render all the Trips to Festivals I have. In my reducer for my trips I set the initial state to an empty array which I eventually will concatenate on when creating new festivals. This is where my serializer comes into play because I utilize the data recieved from my fetch request to grab all of my trips which allows me to access the Festival Name, cost, dates, who’s going, etc.</p><p>Next I refactored my code to to utilize react-router-dom. One of the main benefits of using Browser Router(which I wrapped my &lt;App&gt; in) is that it gives your routes/links props. One of the ones I used frequently was history which allowed me invoke .push and push to a different route.</p><p>EX: When creating a new trip within the function I use history.push(‘/mytrips’) which then redirects the page to show all of the trips that belong to that user.</p><p>Same for my Logout button. Because I have rendered my Logout button in a Route, I have access to history and once clicked my page reroutes to my login and signup page. Some other props are location and match. Match will hold a dynamic piece of url.</p><p>Need to add info on deleting festivals and updating them as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7352be563126" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Project]]></title>
            <link>https://dvlpher.medium.com/javascript-project-fa8eedb79370?source=rss-f5f7c3c16f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa8eedb79370</guid>
            <dc:creator><![CDATA[Celeste]]></dc:creator>
            <pubDate>Mon, 26 Apr 2021 18:17:24 GMT</pubDate>
            <atom:updated>2021-04-27T00:58:02.345Z</atom:updated>
            <content:encoded><![CDATA[<p>I really enjoyed creating this project. I think it tested me a lot more than our previous ones. To start I mapped out my project and decided that I would create a meal tracker. The associations are as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*gt34WXwSMZr5m28cKS2WlQ.png" /><figcaption>Category has many Meals</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*ZnIp0OZ7oE-swD4XeTb9VQ.png" /><figcaption>Meals belongs to a Category</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uupxawh_3WGmAy0Ejsil-A.png" /><figcaption>Seed Data</figcaption></figure><p>When setting up my project I created my frontend and backend in completely different folders. From what I read your api can be compatible with other front ends so it is best practice to keep them separate. Next, I prepped my database for my db I used postgresql</p><p>rails new meal_tracker_backend — database=postgresql — api</p><p>I then linked my created repo to my github repo.</p><p>Once I created all my migrations, associates, and ,models I set up the routes for my api.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7XKezieyt-LXauOfp999sA.png" /><figcaption>I created, index and create first for my meal and index for my category</figcaption></figure><p>I utilized namespace so that I could indicate that this route is used for an api as well as indicated that it was version one. To confirm my routes were working I started my rails server using “rails s” ran “rails routes” then accessed my index for meals which shows my database data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E3qTcz5jKwNXSDZnvGAwfg.png" /><figcaption>api data shown in the data array due to my serializer and utilization of Fast JSONAPI</figcaption></figure><p>Within my index method in my meals controller I render json directly vs .erb as we are utizling js additionally this allows us not to have to use @(instance) in front of our variables as they will not have to be rendered in the erb files. Rendering json allows our fetch get request to return all instance of the Meal class.</p><p>WILL COME BACK TO TALK ABOUT CREATE METHOD</p><p>Next I created my serializers, I created both a category and meal serializer utilizing first: the fast_jsonapi gem and secondly: “rails g serializer meal” which gives access to the nested data within the data key. Once the serializers were created I listed the attributes I wanted to bring in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*ycSObmmEwMYP10s0XBwYPg.png" /><figcaption>ensured I added :category so that I could see the association in the data key. i.e data.attributes.category.name</figcaption></figure><p>Once I have created my serializer I went back to my meals controller and updated the index method to utilize the serializer which makes the data passed through the api to frontend easier to read and more accessible.</p><p>Now I have a fully operational API, I will touch on the destroy method later as I added that last.</p><p>When starting my frontend I first created two files index.html and index.js as of then my files were not connected to connect them I had to add a script tag which told my html file to load my index.js file and later on my meal.js file.</p><p>&lt;script <em>type</em>=”text/javascript” <em>src</em>=”src/index.js”&gt;&lt;/script&gt;</p><p>&lt;script <em>type</em>=”text/javascript” <em>src</em>=”src/meal.js”&gt;&lt;/script&gt;</p><p>The html files renders the structure(view) of our frontend which allows us to have to refresh our page to update it, we can use DOM Manipulation.</p><p>To start I made sure that my DOM content was loading properly and my files were connected.</p><p>document.addEventListener(“DOMContentLoaded”, () =&gt; { console.log(“Content has Loaded.”) }</p><p>This ensures that 1. My files have connected successfully and 2. My content has loaded properly. The reason I checked my api routes earlier is to ensure they are working which ensures that I am able to do a fetch request from it. The initial fetch request I use is a GET request because I want to <em>get</em> data to render onto my page. Later I will use a POST request because I want to be able to post new data onto my API, and after that I will do a DELETE request to be able to remove data from my page.</p><p>Because I am running my backend and frontend locally I had to enable the ‘cors’ gem which allows me to run both on cross-origin platforms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*mZYiOEa9-OrTOOVRMLJEuQ.png" /><figcaption>loaded on DOM when page is rendered to show all meals in api.</figcaption></figure><p>I load getMeals() in the DOM Content which renders all of my meals utilizing a GET request. the meal-container is within my html and I manipulate that to add each meal to my page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*M6bwXBl3W7xWxuNSxRyL7g.png" /><figcaption>I use a GET request here to request the meals from the api endpoint</figcaption></figure><p>When creating a new meal on my page I utilize a POST fetch request with allows me to “post” to my api the added information. I utilize the Class and the constructor method which is similar to the initialize method used in rails. I utilize the function createFormHandler to once prevent my page from refreshing and also to grab all the information to create a new instance in the api. This function must be utilized after the submit action is clicked to ensure I can grab the data as well as to ensure the page does not refresh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*ZsvJJAclimd1zjDamlS-DQ.png" /><figcaption>I use parseInt to convert the string number value into an integer.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa8eedb79370" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Rails Project]]></title>
            <link>https://dvlpher.medium.com/my-rails-project-99f022548959?source=rss-f5f7c3c16f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/99f022548959</guid>
            <dc:creator><![CDATA[Celeste]]></dc:creator>
            <pubDate>Tue, 08 Dec 2020 00:13:24 GMT</pubDate>
            <atom:updated>2020-12-11T20:33:20.985Z</atom:updated>
            <content:encoded><![CDATA[<p>When starting my rails project though I understand relationships so: has_many and belongs to, I really struggled with picking the basis of my project. It felt like every thought I had it felt limited. But ultimately I decided to go with Users, Profiles, and Games.</p><p>A user has many profiles and has many games through profiles.</p><p>A game has many profiles and has many users through profiles.</p><p>A profile belongs to a user &amp;&amp; belongs to a game.</p><p>To start I outlined my project by attributes per model and and wrote out how they would associate to one another.</p><p>First I created the table for each model</p><p>Users —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*QtGn6U59hWgOgG9Eqm44Sg.png" /><figcaption>Users has many Profiles and has many Games through Profiles</figcaption></figure><p>Games —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*MkToDOPuaRKu7RKl5V-GUg.png" /><figcaption>Games has many Profiles and has many Users through Profiles</figcaption></figure><p>Profiles —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*42O7devA-CB9kXm9ZPQGyg.png" /><figcaption>Belongs to Games, Belongs to Users</figcaption></figure><p>I want to note that though user’s have an attribute of “uid” that didn’t come until I implemented the facebook oauth that allows users to login through their facebook account. Which required an env file to place my FACEBOOK_KEY and my FACEBOOK_SECRET. These are require to allow a user to login through facebook and store their login information.</p><p>I started with thinking out my routes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wjoTtR0I_b1R3bTXF2bYeA.png" /></figure><p>You will see that I have nested my profiles routes within my games routes so if a user wants to create a profile directly linked to the game they can go to games/1/profiles/new and in this example it would make a profile for the game cyberpunk.</p><p>The root path would be what my users see when they are at my ‘/’ page.</p><p>Lastly, I created custom paths to map to some sessions controller actions</p><p>Next I created each of my models where I inputed various validations and scope methods. We see on the the All Profiles page we have a scope method that allows you to search by progress percentage. I also created other scopes that I haven’t implemented but may later down the road.</p><p>In my application controller I made a helper method that allowed me to user current_user and logged_in? at the same time through the method “check_if_logged_in”</p><p>Next I created all of the controllers for sessions, users, profiles, and games and created their respective methods needed.</p><p>My favorite part was forms, because that’s when you’re able to see everything come to life. I really took advantage of partials here which cuts the workload in some places by 2/3. For example I was able to use my _form from profiles in my profiles new and in my profiles edit. and what was even cooler to me was that I was able to create a partial in my application controller for my errors and place that within my form partials.</p><p>In my profiles index view is where I implement my scope methods. In the index action in my profiles controller I order the profiles by last_played and in my view I allow a user to search my progress.</p><p>Add- I just added an index page for all my user’s that allows another user to see the user and all the games they own.</p><p>Lastly, I created a logout method that when a user presses the logout button it will reroute them to the welcome page.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99f022548959" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First Sinatra Program]]></title>
            <link>https://dvlpher.medium.com/my-first-sinatra-program-477cb5d5bb5?source=rss-f5f7c3c16f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/477cb5d5bb5</guid>
            <dc:creator><![CDATA[Celeste]]></dc:creator>
            <pubDate>Fri, 21 Aug 2020 19:58:44 GMT</pubDate>
            <atom:updated>2020-08-21T20:10:28.776Z</atom:updated>
            <content:encoded><![CDATA[<p>WOW! I start with that because this past month has been a journey but it has taken a break with me successfully creating my Sinatra project! For our project we had to implement MVC(Model,View,Controller), be able to successfully use ActiveRecord, have multiple models, have a has_many relationship/belongs_to relationship.</p><p>First I used the corneal gem to create my Sinatra project file structure. Corneal is an extremely helpful gem that literally builds out our your MVC files. When taught I was given the following analogy to understand MVC as a kitchen.</p><p>Model — Is the Chef, it creates everything the customer will need to eat</p><p>View — Is the plate of Food, it is what the customer sees without knowing what it takes to make</p><p>Controller — Is the Waiter, it’s able to talk to both the chef and the customer to make sure each get the information they need.</p><p>Next, I created the Model for our User. I need the user Model created in order to create my users db. For my User model, I will need a name, bio, image_url, email and password. In my database in order to activate the bcrypt gem we use password_digest instead of simply password as it allows us to encrypt the users password so it is not stored raw locally. In order for this to be possible we need to return to the User model and add has_secure_password. The has_many macro has a method called “authenticate(password)” that checks password against the password_digest data and the gem ’bcrypt’s algorithm verifies whether or not it is the right password.</p><p>For my first database I created it on my own using rake db:create_migration NAME=create_users. But I learned that I can use the corneal gem to create a database and I was able to do so using the following code:</p><p>corneal model shoe title:string image_url:string description:text user_id:integer</p><p>I used text instead of string for the description because though it’s a high limit there is still a limit for strings. Additionally, I created user_id(a foreign key) to associate the shoes to their owner.</p><p>To establish the associations I used the has_many and the belongs_to associations. Which within the user model will say: has_many :shoes(plural) and within the Shoe model we use the belongs_to association: belongs_to :user(singular).</p><p>After creating both database tables I run: rake db:migrate and to confirm everything has migrated successfully I can check my db/schema.rb</p><p>Next I need Seed Data. Seed Data is fake data that we create to test our program. One thing I learned through this project is how to create, and destroy users. but what I found was that when I destroyed all users or shoes the id’s stayed for example in my head I deleted the two users and when I reran rake db:seed instead of the user’s id’s being 1 &amp; 2 they were 3 &amp; 4. To rectify that I had to delete the development.sqlite file and the schema.rb file and re migrate my tables.</p><p>Once my seed data was available I ran ‘tux’. The tux gem allows me to verify my associations.</p><p>Moving on I opened my first controller application_controller.rb this controller was created by corneal. This controller contains the first view the user will see. they will see the first get route we have is our home page ‘/’ This brings our users to the Welcome page of our program which allows them to either sign up or log in. The view rendered in this route is welcome.erb. It also worth noting that we have helper methods that are accessible throughout all controllers. We see those accessed in the ‘/’ we use the helper method “logged_in?” which confirms if the if the current_user method either returns a hard true or false. Which we use it saying “is this user logged in?” if they are take them to their home page, if not take them to the welcome page to either log in or sign up.</p><p>In the welcome.erb I created two links that either take the user to the ‘/login’ route or the ‘/signup’ route. When the user signs up we see that they must fill out every field as within the user.rb I used validates :title, :image_url, :description, presence: true. Which in less words means make sure these fields are there and filled.</p><p>Next I move to the users_controller and created my login get request that renders a login.erb which renders a form for the user to fill in their credentials. We then post that data to our login post request that verified 1. if the user exists AND if the users credentials are valid. If those are both true it will render the sinatra::flash gem I installed and configured in my layout.erb.</p><p>Sidenote: layout.erb is what the websites layout will ALWAYS have. Example: a logo, a navigation bar, etc.</p><p>Now if the user were to select sign up on the ‘/’ page the link would take them to the ‘/signup’ request. Once successfully signed up or logged in I take the user to their home page. Here they will see their profile picture, name, an option to see everyone’s shoes including their own, an option to add a new shoe and finally to log out.</p><p>If a user goes to all shoes, they have tapped into the shoes_controller. Here they will see all shoes that have been created by ALL users. BUT the cool thing is though they will be able to view all shoes, they will only be able to delete and edit the one’s associated to their user_id. and if the user manually tries to edit the path to edit a shoe that isn’t theirs it will redirect them to all shoes and flash a “not authorized to do so” message.</p><p>What I found difficult was the delete and patch routes, not the actual act of them but for example I wrote them out and was getting errors. Shout out to my cohort lead Michael who explained that in the config.ru order matters. so the Rack::MethodOverride that gives us access to both edit and delete has to be placed before the mounting of the controllers.</p><p>Moving on I found that the Sinatra-Flash gem was SUPER cool and helpful. it allows you to flash an error message once on get requests and redirects only. So for example when a user didn’t enter an image_url for their shoe they would see an error stating they must enter a image.</p><p>Lastly, if a user decides to log out it will redirect them to the home page. Note: if while logged in the user goes to the “home page” it will take them to their profile. If they are not logged in it will take them to the home page that allows them to log in or sign up.</p><p>This project was a real testament to my determination and resilience. In July my dog Cash was diagnosed with cancer, this week he passed away. It hasn’t been an easy road but it’s one I know I’m suppose to be on and that I’m working hard for.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=477cb5d5bb5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First Project — EVER —]]></title>
            <link>https://dvlpher.medium.com/my-first-project-ever-5cf6642f4a25?source=rss-f5f7c3c16f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cf6642f4a25</guid>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[marvel]]></category>
            <category><![CDATA[superheroes]]></category>
            <dc:creator><![CDATA[Celeste]]></dc:creator>
            <pubDate>Sun, 07 Jun 2020 18:36:33 GMT</pubDate>
            <atom:updated>2020-06-07T18:36:33.232Z</atom:updated>
            <content:encoded><![CDATA[<h3>My First Project — EVER — CLI</h3><p>I’ve struggled a bit with figuring out how to write my first technical blog for my first project but I guess there’s a first time for everything. I started trying to gather information about my initial API which was going to be song lyrics, my thought was to return a list of artists, then the user selects the artist which then gives them a list of songs, lastly the user selects the song they want and it will return the song lyrics. THAT DIDN’T WORK. I just couldn’t find an API that did all of those things it was either just song lyrics or just the artist. I imagine if I dove a little deeper I may have been able to find an API with those capabilities but we’ll get there. I then found a Super-hero API. Side note: API means Application Program Interface. Moving on, the super-hero api I found did not have an initial list. Then I found the Marvel API.</p><p>MARVEL API DOCUMENTATION: <a href="https://developer.marvel.com/documentation/generalinfo">https://developer.marvel.com/documentation/generalinfo</a></p><p><a href="https://developer.marvel.com/docs#!/public/getCreatorCollection_get_0">https://developer.marvel.com/docs#!/public/getCreatorCollection_get_0</a></p><p>The Marvel API was all things wonderful and terrifying at the same time. First thing was determining what the base url was:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aayxjZ9T4es7t-9EOYgmtA.png" /><figcaption>Marvel Base Url</figcaption></figure><p>You’ll see multiple string interpolations inside this base url. We have TS(Time Stamp), Your API Public key, and a Hash, which uses the digest gem to encrpt your timestamp, public key, and private key with an alias.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gMBSJGooArvu4bl9q7DCYQ.png" /><figcaption>How to generate base url for Marvel API</figcaption></figure><p>I have stored my public and private key in a env file to hide them but also be able to pull them into my base url as needed.</p><p>The base url on initial use gives us only 20 instances of superheros, and to make matters a little worse the max you can pull at one time is 100 superheros. If we wanted to grab all 1400 objects we would need to use the base url + a limit of 100, and the offset each url in increments of 100. For the purpose of not providing 1400 options, I limited my options to 200(had to include my favorite Black Panther).</p><p>Next, I made a get request(well two) one starting at the first super hero the next starting at superhero 101.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZA9RnNS9zIa3md_BZ8pXVw.png" /><figcaption>Get Request on Marvel API</figcaption></figure><p>In the code above we grabbed the first 100 objects and saved the Name, Description, Bio, Comic, Image, ID, and the Marvel_ID. I added a counter because I could not figure out how to determine how Marvel determined the Marvel ID, and I need that info later on when I do my third get request to pull in the first available comic for that particular superhero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EOmAdzYjcBEyluFbYRWWSA.png" /><figcaption>Initialize method for initial superhero objects.</figcaption></figure><p>In our get_characters method we call .each on the data pulled but within that each method we use the data we pulled and saved in our variables to initialize our Superhero objects. Notice within my initialize method I run an if statment because when a superhero doesn’t have a description it stores the variable as “” rather than nil. Meaning if I would have put my default value within the arguments i.e: description = “This Superhero does not have a description.” It would have never triggered because the value is “” and not nil. So my if statement checks if the value is “” and if it is we overwrite it with our default value, if not, we save the description given.</p><p>I also have a class hash named choices that is used in my CLI that stores the name as the Key and the ID as the value. As well as a class array name all that stores all of the super hero objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*qRL-wnqVpgG-6KSjINwK-w.png" /><figcaption>Class Methods</figcaption></figure><p>I have made two class methods that simply return the objects in that array and hash we spoke about above which come in handy later on.</p><p>In my CLI I’ve used a gem “tty-prompt” which makes “pretty” menu options.</p><p>We find the documentation here: <a href="https://github.com/piotrmurach/tty-prompt">https://github.com/piotrmurach/tty-prompt</a></p><p>This prompt we use allow us to present the options in our menu in increments of 20. It also uses the Choices hash we created to list the superheros by ID and their names. It also takes in the user response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lqG_ze0c3wk6Xoev2tZx-A.png" /><figcaption>CLI prompt (note: \n creates a new line)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iO04vAB2dxQf6i8SwACcoQ.png" /><figcaption>running bin/run, runs Cli.new.run which starts the Cli program with the run method.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*-l0NCoC_A5VeVMI_euWmdQ.png" /></figure><p>Upon running the Cli file we run Api.get_characters to instantiate all superhero instances and make them obtainable.We then run main.</p><p>Based on the response given by the user we print the initial details we are given for that superhero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*RericElfqZjZnkHk_oq6Ag.png" /><figcaption>First request prints the above details</figcaption></figure><p>We then give the user the option of exiting the program or accessing the first comic available for that superhero. If the user selects yes we then run our 3rd get request to obtain all of the information for that superhero’s first available comic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*10nNfZN0QDzcvSDNy45xCA.png" /></figure><p>Based on the selected superhero we grab that superhero’s marvel id and place that inside of an altered base url. We then use the each method to update each Superhero object to now include title, comic_description, page_count, available_copies, purchase_link, print_price, and digital price. Then it returns the updated superhero instance. Which is what the user would see.</p><p>Lastly the user has the option to restart the whole process or exit the program.</p><p>All in all, this experience was a wonderful one. A challenging one but one that showed me 1. You got this! 2. You’re persistent 3. You’re able to get things done when you have a solid support system, foundation and determination to get things done.</p><p>I also found it very helpful for me to help my cohort mates. It showed me that I understood what I learned and also that I was able to help others which was probably the best part. I’m super excited for what will come ahead!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cf6642f4a25" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>