<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jakob Persons</title>
    <description>The latest articles on DEV Community by Jakob Persons (@jpersons24).</description>
    <link>https://dev.to/jpersons24</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F634449%2Fb3146efe-d3b3-4353-8ac4-0d8f56035af0.jpg</url>
      <title>DEV Community: Jakob Persons</title>
      <link>https://dev.to/jpersons24</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jpersons24"/>
    <language>en</language>
    <item>
      <title>My Personal Assistant has been slacking off</title>
      <dc:creator>Jakob Persons</dc:creator>
      <pubDate>Tue, 22 Jun 2021 14:41:49 +0000</pubDate>
      <link>https://dev.to/jpersons24/my-personal-assistant-has-been-slacking-off-5hcd</link>
      <guid>https://dev.to/jpersons24/my-personal-assistant-has-been-slacking-off-5hcd</guid>
      <description>&lt;p&gt;Previously I posted about the pre-planning and initial build of my app, Associate. &lt;a href="https://dev.to/jpersons24/creating-my-own-personal-assistant-5go6"&gt;"Creating My Own Personal Assistant"&lt;/a&gt; ended on the setting up of relations between different Active Record models that were created.&lt;/p&gt;

&lt;p&gt;Our database structure and relationships remain the same. Serializers have been used as well to ensure specific JSON data structures are received on the server side in a friendly way. Within the Rails application, the &lt;code&gt;./Gemfile&lt;/code&gt; has the active record gem: &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4yl2Btzb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jxteq70aerdkhwpowwdu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4yl2Btzb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jxteq70aerdkhwpowwdu.png" alt="ActiveModel Gem syntax"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We now have the ability to set these serializers, so that when we have access to a User object, we also have access to the plans, assessments and reflections that fall under the User's umbrella. From our &lt;code&gt;./app/serializers/user_serializer.rb&lt;/code&gt; file we have the following syntax: &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Koh237wY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ogbwxwca2lsj0zw0ppf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Koh237wY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ogbwxwca2lsj0zw0ppf.png" alt="Active-Record-Serializers"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Other than that, everything else on the server side has remained the same. What's drastically changed is the frontend of my personal assistant application. I have added a react app using the &lt;code&gt;npx create-react-app associate&lt;/code&gt; command.&lt;/p&gt;

&lt;h2&gt;
  
  
  React Frontend
&lt;/h2&gt;

&lt;p&gt;At present, our application looks like this upon starting the server. &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JF0u2ZRj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/636q2iqp4gbocjw26wx4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JF0u2ZRj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/636q2iqp4gbocjw26wx4.png" alt="Current App Render"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please don't mind the less than ideal color scheme&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Our component hierarchy has a few added pieces, but the main tree containing all of our Active Record Models is still intact. Using our &lt;a href="https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en"&gt;React Developer Tools&lt;/a&gt; we can see the component hierarchy in it's current state: &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--589cgvFK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ujggame5v72hwy0hsi4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--589cgvFK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ujggame5v72hwy0hsi4.png" alt="Hierarchy Tree"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see here, at the bottom of the tree I have an &lt;code&gt;AssessmentCenter&lt;/code&gt; component. This is a child of the &lt;code&gt;Dashboard&lt;/code&gt; component, but is also a parent to the &lt;code&gt;Reflection&lt;/code&gt; and &lt;code&gt;Assessment&lt;/code&gt; components. This is why it is important to utilize serializers on the server side within Active Record. It gives me the ability to access a User's Assessment and Reflection objects without making unnecessary server requests. Here is what our serializers provide for us:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EmLBWwHk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ea3w7qg1yy87nqs0m9b3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EmLBWwHk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ea3w7qg1yy87nqs0m9b3.png" alt="JSON serializer output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This displays what just one User object provides to us. From a simple call to the server, we have access to all data related to that User. All you need to do is access the nested data using dot notation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current Hierarchy Status
&lt;/h2&gt;

&lt;p&gt;We saw the complete component hierarchy above. Let's dive into that a bit. The App component is the overall Parent component, which contains the &lt;code&gt;Dashboard&lt;/code&gt; component. &lt;code&gt;Dashboard&lt;/code&gt; has &lt;code&gt;ResourceContainer&lt;/code&gt;, &lt;code&gt;AssessmentContainer&lt;/code&gt; and &lt;code&gt;AssessmentLibrary&lt;/code&gt;. &lt;code&gt;ResourceContainer&lt;/code&gt; and &lt;code&gt;AssessmentContainer&lt;/code&gt; also have multiple children components. Why such a complex (relatively speaking of course) component hierarchy for such a simple application?&lt;/p&gt;

&lt;p&gt;Well, it helps me to stay organized within the structure of my applications. Additionally, when other developers look at my code, I want them to be able to easily read and dissect the code. Following the &lt;a href="https://reactjs.org/docs/thinking-in-react.html"&gt;Thinking In React&lt;/a&gt; methods, especially the Single Responsibility Theory - which is the idea that each component should have a single responsibility, my goal is to keep organized for easily adding features in the future.&lt;/p&gt;

&lt;h2&gt;
  
  
  Moving Forward
&lt;/h2&gt;

&lt;p&gt;My aim is to get my personal assistant back to work. It's vital that I provide organization, simplicity and the proper data tools to have it running its best.&lt;/p&gt;

&lt;p&gt;Please feel free to check out the repository on &lt;a href="https://github.com/jpersons24/associate"&gt;GitHub&lt;/a&gt;. I'm always open to feedback and general discussion. Stay tuned for an update soon, as this blog starts my 30 day blog challenge!!!&lt;/p&gt;

</description>
      <category>rails</category>
      <category>react</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Creating My Own Personal Assistant</title>
      <dc:creator>Jakob Persons</dc:creator>
      <pubDate>Sun, 30 May 2021 17:50:46 +0000</pubDate>
      <link>https://dev.to/jpersons24/creating-my-own-personal-assistant-5go6</link>
      <guid>https://dev.to/jpersons24/creating-my-own-personal-assistant-5go6</guid>
      <description>&lt;p&gt;Planning and executing a career pivot and consequential job search that follows is no small task. There are endless tools at our disposal designed to aid us in organization, production, value creation, communication and much more. As a software engineer, I'm always looking for the best tools to use, so I thought to myself - why not just build my own?&lt;/p&gt;

&lt;p&gt;So, that's what I am doing. This blog will cover my process in initial app creation and design plan for my personal app called &lt;em&gt;Associate&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Application Design and Architecture
&lt;/h2&gt;

&lt;p&gt;Associate is built with a Ruby on Rails backend. Using Active Record ORM framework and Postgres database. Before actually going to our command line with &lt;code&gt;rails new associate&lt;/code&gt;, it's important to create an ERM and user stories that guide development. ERM (Entity Relation Map) shows objects and their relationships, and are subject to change as development progresses.&lt;/p&gt;

&lt;h4&gt;
  
  
  Creating an ERM
&lt;/h4&gt;

&lt;p&gt;For my purposes we will have a few objects, or entities, to map out. I always find it best to draw it out with pen and paper to get started, there are however multiple tools that you can use to help illustrate these relationships.&lt;/p&gt;

&lt;p&gt;Here is the original ERM that I created for Associate.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ms5TEAsD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a49sgnilj1dx8x06gc42.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ms5TEAsD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a49sgnilj1dx8x06gc42.png" alt="Screen Shot 2021-05-30 at 11.58.21 AM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;USERS&lt;/strong&gt; have a one to one relationship with &lt;strong&gt;PLANS&lt;/strong&gt;. This means that a User object has 1 and only 1 Plan. In this case, the foreign key goes lives with the Plan model and points to the User ID that it belongs to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PLANS&lt;/strong&gt; also have many &lt;strong&gt;ASSESSMENTS&lt;/strong&gt; and &lt;strong&gt;REFLECTIONS&lt;/strong&gt;. They have a one to many relationship. This represents in real life the many reflections and assessments that a Plan would have.&lt;/p&gt;

&lt;h4&gt;
  
  
  Creating Database and Active Record Objects
&lt;/h4&gt;

&lt;p&gt;Now, creating the Rails application and database together should be relatively simple now that our ERM is setup.&lt;/p&gt;

&lt;p&gt;Using the &lt;a href="https://guides.rubyonrails.org/getting_started.html"&gt;Ruby Guides&lt;/a&gt; to get started, there are a number of steps to get everything setup.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After checking that Ruby and Rails versions are installed on your local machine, you can generate the initial app with the following command: &lt;code&gt;rails new associate&lt;/code&gt;. Where associate is the name of your application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I prefer to use postgres database so there is a little more to the &lt;code&gt;rails new&lt;/code&gt; command that we need to include. Additionally, since I am using Ruby on Rails as an API we can include that in our command as well.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rails new associate --api --database=postgresql&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After running this command, your rails app will be generated with the file structure necessary for use as an API. Checking the config/database.yml file, make sure the database adapter is set to postgres. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VAp1T_Ic--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r90bpboc9jtoydcttq1x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VAp1T_Ic--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r90bpboc9jtoydcttq1x.png" alt="Screen Shot 2021-05-30 at 1.28.16 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You'll also want to make sure your Rack CORS setup is taken care of. In the Gem file, you'll need to install the &lt;code&gt;cors gem&lt;/code&gt; which can be found &lt;a href="https://github.com/cyu/rack-cors"&gt;here&lt;/a&gt;. After adding to your Gem file, make sure to run bundle install from your command line again.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally within &lt;code&gt;config/initializers/cors.rb&lt;/code&gt; file you'll want the following code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VSzeDgyW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11df3cwygtbf096e1cws.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VSzeDgyW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11df3cwygtbf096e1cws.png" alt="Screen Shot 2021-05-30 at 1.31.09 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that the environment and setup is complete, from our command line we can create the models and associations that we need before finally creating our database.&lt;/p&gt;

&lt;p&gt;You will need to run the following commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;rails g resource users name email password_digest linkedin website github&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;rails g resource &amp;lt;model name&amp;gt; &amp;lt;attribute&amp;gt;&lt;/code&gt;&lt;br&gt;
the attributes will default to string. If you for instance wanted an attribute to have a data type of integer, the syntax would look like this: &lt;code&gt;rails g resource users age:integer&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;rails g resource plans app_target:integer net_target:integer current_app:integer current_net:integer belongs_to:user&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;the &lt;code&gt;belongs_to:user&lt;/code&gt; piece creates a foreign key within the plans model. This is where the association between these models are made. Plan would then have a attribute name called user_id which would have the value of the id of the user that the plan belongs to.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After creating the final too models for assessments and reflections, making sure to add foreign keys to each of them for plan, within each model.rb file you can complete the associations with the following:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;User should have one Plan. Plan should belong to a User. Plans should have many assessments and reflections, and assessments and reflections should belong to a Plan. The screenshots below show how you can do this.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5&gt;
  
  
  User Model
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K5s7-qxz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ngdtg8dy68k6z2ufhrcg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K5s7-qxz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ngdtg8dy68k6z2ufhrcg.png" alt="users"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Plan Model
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NdPhHtc0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5fpcwb5ifoa6ofipmb7g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NdPhHtc0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5fpcwb5ifoa6ofipmb7g.png" alt="plans"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Assessment Model
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kNJjBNPU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nbln8o291rz1qgt52615.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kNJjBNPU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nbln8o291rz1qgt52615.png" alt="assessment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Reflection Model
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s_PLfAPk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mzjp8lbue5uzxuvxivjy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s_PLfAPk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mzjp8lbue5uzxuvxivjy.png" alt="reflections"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that all the Models and there associations are created you can run the final few commands to get the database setup.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;rails db:migrate&lt;/code&gt; will run all migration files and create the schema for the database&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rails db:setup&lt;/code&gt; will create the database and load the schema created from the previous migrate command.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once these commands are done, the database and correlating tables and columns for each model are created and you can begin next steps of building routes and action methods within the model controllers.   &lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
    </item>
  </channel>
</rss>
