<?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: AaronDski</title>
    <description>The latest articles on DEV Community by AaronDski (@aarondski).</description>
    <link>https://dev.to/aarondski</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F670322%2F1e93276c-4dd6-4c00-8fab-b9c5d37aa026.jpeg</url>
      <title>DEV Community: AaronDski</title>
      <link>https://dev.to/aarondski</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aarondski"/>
    <language>en</language>
    <item>
      <title>Useful VSCode Extensions</title>
      <dc:creator>AaronDski</dc:creator>
      <pubDate>Fri, 24 Sep 2021 15:40:17 +0000</pubDate>
      <link>https://dev.to/aarondski/useful-vscode-extensions-23d6</link>
      <guid>https://dev.to/aarondski/useful-vscode-extensions-23d6</guid>
      <description>&lt;p&gt;VSCode (Visual Studio Code) is one of many code editors. A few of them are &lt;a href="https://atom.io/" rel="noopener noreferrer"&gt;Atom&lt;/a&gt;, &lt;a href="https://www.sublimetext.com/" rel="noopener noreferrer"&gt;Sublime&lt;/a&gt;, and &lt;a href="https://brackets.io/" rel="noopener noreferrer"&gt;Brackets&lt;/a&gt;. All of these text editors have their pros and cons, advantages and shortcomings. Needless to say, they are all similar in the fact that they were created to make writing code easier for the coder. The languages, libraries and frameworks that I use regularly are JavaScript, React, Ruby, and Ruby on Rails. &lt;/p&gt;

&lt;p&gt;Here are some of my favorite extensions and why.&lt;/p&gt;

&lt;p&gt;1) &lt;strong&gt;Bracket Pair Colorizer.&lt;/strong&gt; It does what the name suggests: this extension makes reading and debugging easier. You can see that it will also add a colored line to the pair of brackets or parentheses. &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi500ae1ke251tikdiiho.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi500ae1ke251tikdiiho.png" alt="Colored Line Demo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Although I have not set this up on my own VSCode, you are also able to customize when the brackets change color.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvrve93akhtplore5e1e6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvrve93akhtplore5e1e6.png" alt="Diff Bracket Colorization"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even the standard configuration is a great setup and has been very helpful at reducing syntax errors.&lt;/p&gt;

&lt;p&gt;2) &lt;strong&gt;Rainbow End&lt;/strong&gt; is along the same vein and colors your &lt;em&gt;ends&lt;/em&gt; in Ruby (it works with other languages as well). It has been very easy to identify when I am missing an &lt;em&gt;end&lt;/em&gt; or if I have to many ends. Here are some examples of Ruby methods with Rainbow End enabled:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftqy04a67i4rwuegdcbwy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftqy04a67i4rwuegdcbwy.png" alt="Ruby with Rainbow End"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3) &lt;strong&gt;Draw.io Integration.&lt;/strong&gt; If you work on your own projects, I'm sure that you have at least &lt;em&gt;heard&lt;/em&gt; of &lt;a href="https://drawio-app.com/" rel="noopener noreferrer"&gt;Draw.io&lt;/a&gt;. It is a user-friendly web app for making diagrams. The &lt;strong&gt;integration&lt;/strong&gt; extension is not officially from Draw.io, but this particular extension is very useful as it allows you to have any and all of your relevant diagrams in your project file, which ends up being a big time saver. I have not tested the full capabilities of this extension yet, but I'm sure that there are plenty of features that I would like.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmq1pkq1yn91d96pe9qyr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmq1pkq1yn91d96pe9qyr.png" alt="Draw.io in VSCode"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The only drawback that I have run into is, when I have a large diagram up on one side of my VSCode and the code that I am editing on the other side, I will sometimes have to scroll through the diagram because I can't see the full diagram or have it on a separate screen.&lt;/p&gt;

&lt;p&gt;These next few extensions come with a caveat, as they can instill some bad habits. So use with caution. &lt;/p&gt;

&lt;p&gt;4) &lt;strong&gt;Endwise&lt;/strong&gt; is nice because it will automatically add &lt;em&gt;end&lt;/em&gt; when you are writing methods in Ruby. It is also pretty intuitive at knowing when an &lt;em&gt;end&lt;/em&gt; is needed or not. This gif is not a great example but you can get an idea of how it works:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwkcquor0pht9ctigtwhl.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwkcquor0pht9ctigtwhl.gif" alt="Endwise Gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The downside this is that you can become reliant on the extension to add all of your &lt;em&gt;ends&lt;/em&gt;, and then you have a propensity to completely forget common syntax of the coding language. &lt;/p&gt;

&lt;p&gt;5) &lt;strong&gt;Tabnine&lt;/strong&gt; is another "double edged sword" extension. This is an autocomplete, or AI-assisted code completion, AI-powered code completion, AI copilot, AI code snippets... whatever you want to call it is up to you, but it can definitely help to save time. I like to use longer names for my function names, so the autocomplete is great for saving key strokes. I'm not the greatest at spelling so the spellcheck is also nice. It does have some quirks as well, especially when it tries to be &lt;em&gt;too&lt;/em&gt; helpful by giving you suggestions that you don't need or want. Like this  &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftmt6aixgprty2llfgjtx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftmt6aixgprty2llfgjtx.png" alt="Tabnine"&gt;&lt;/a&gt; I only want the method of &lt;em&gt;show&lt;/em&gt; and it thinks I would like &lt;em&gt;show_exceptions&lt;/em&gt;, which hinders me from being able to just hit enter and go to the next line, as I would normally do. There is a shortcut to bypass this suggestion from Tabnine: you can hit "command + enter" for Mac or "control + enter" for PC, and it will move you to the next line.&lt;/p&gt;

&lt;p&gt;All these extensions have been very helpful for me in my projects. I am sure that there are a number of other extensions out there I have yet to discover and may find even more useful, but for now, these are some my favorites. I hope that these can be helpful to you as well.&lt;/p&gt;

&lt;p&gt;Postscript: A good indicator to determine if an extension is noteworthy or relevant is by looking at how many downloads it has and if there have been recent updates/responses to questions by its originator. &lt;/p&gt;

&lt;p&gt;Comment below about your favorite extensions.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>vscode</category>
      <category>extensions</category>
      <category>shortcuts</category>
    </item>
    <item>
      <title>GitHub Workflow,  Merge and Rebase</title>
      <dc:creator>AaronDski</dc:creator>
      <pubDate>Fri, 10 Sep 2021 19:16:34 +0000</pubDate>
      <link>https://dev.to/aarondski/github-workflow-merge-and-rebase-1cig</link>
      <guid>https://dev.to/aarondski/github-workflow-merge-and-rebase-1cig</guid>
      <description>&lt;p&gt;If you are just getting into coding and are working on projects, ether solo or in a group, you probably use GitHub, a platform to house your projects. Or you use it at your job and are always doing adds and commits, waiting for you superior to approve the merge. If you already know how all of that works, then you most likely won't need to read this post. I am writing this as more of a quick reference guide for us newbies... and there is a lot of additional good documentation from GitHub and lots of extra resources on the web.&lt;/p&gt;

&lt;p&gt;There are 2 major ways to update a main/master branch in GitHub: the first is the good old &lt;code&gt;git merge&lt;/code&gt;, and the second is &lt;code&gt;git rebase&lt;/code&gt;. Both of these commands accomplish the same thing: they update the main/master branch with your newly written code.&lt;/p&gt;

&lt;p&gt;This is coming from the view point that you are working on a branch that is not the main. Make sure you have the most up-to-date version of the main repository by running &lt;code&gt;git pull&lt;/code&gt;. To make your own branch, you can run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch 
#this will display all of the branches in the current repo
git branch example_branch
#this will make a branch off the main if you are currently on the main branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to get into the new branch we just made. We can do this with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout example_branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So you have been working on a feature for the main code file; let's talk about when you are ready to have your code reviewed and potentially merged into the main branch. First we check the status to make sure we only edited the files we were supposed to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we add all of our changes to the staging area to be committed by running one of the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add .
git add -A
git add 'file name'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your code is ready for a commit. This is where we are able to leave a detailed message about what we did with our code. Here are some commit commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -m "message"
git commit -am "message"
#This command will add your changes and commit them in one go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then once you have your code committed, you can push your code to the origin branch with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally it is ready to be reviewed and sent back for editing, or it can be merged into the main. If there is no more code for you to add, when your branch and the main branch are merged, you have the option to delete your branch. If you will need to use it again soon, then you can just leave it be.&lt;/p&gt;

&lt;p&gt;To merge to 2 branches, we will want to go into the main/master branch, then run &lt;code&gt;git pull&lt;/code&gt;, just in case there have been any changes (it will let you know if you are up to date, or it will automatically load the changes). Our commands can look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#currently not on main branch

git checkout main
#now we are on the main branch

git pull
# just to double check for any changes

git merge example_branch   
#now the branch has been merged into main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hopefully there are no merge conflicts, and if not, you are done! That is the easy way to do a merge and its called a "fast forward merge."&lt;/p&gt;

&lt;p&gt;If you do get some merge conflicts you will need to resolve those conflicts before you can move on. &lt;/p&gt;

&lt;p&gt;A merge is pretty self explanatory, you are combining the contents of 2 items into 1.  There are a few ways that a merge can happen, 1) you can do it strait in your terminal, 2) you can use the GitHub webpage, 3) Github also has an app for OSX that works pretty well.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F53brudbvuzzlixtlx6bd.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F53brudbvuzzlixtlx6bd.jpeg" alt="Merge Sign"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;When there are commits on the main branch that are added after you made your branch, it will prompt what is called a "merge commit," once the merge is initiated. You can leave a message and move on to write more code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhtznp8biw1ckvwyv67y5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhtznp8biw1ckvwyv67y5.jpg" alt="Merge commit image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A merge commit will have a lot of "~" symbols and you need to leave a message to move forward in the commit, it would look like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~
~
~
~
~
~
~
~
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can hit the &lt;em&gt;escape&lt;/em&gt; key, then type &lt;em&gt;&lt;strong&gt;: w q&lt;/strong&gt;&lt;/em&gt; which will save the commit and get you through the merge commit. Then you should double check with &lt;code&gt;git log&lt;/code&gt; to make sure all the commit history looks correct to you. &lt;/p&gt;

&lt;p&gt;"Rebase" is a git command that will get us a similar result of adding our code to the main branch, but it works very differently. Rather than having branches come together into the main, you are basically adding your 'example_branch' onto the end of the master branch. To do this you follow all of the same steps above, but when it comes time to merge, you will instead run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#you will want to be in your "example_branch" when you run this command

git rebase main/master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F833qgimnve3370t1taxk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F833qgimnve3370t1taxk.png" alt="Rebase example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The links below are some good resources that I found, and they go into greater detail of whats going on behind the scenes.&lt;/p&gt;

&lt;p&gt;Resources &lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=oFYyTZwMyAg" rel="noopener noreferrer"&gt;GITHUB PULL REQUEST, Branching, Merging &amp;amp; Team Workflow&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=7Mh259hfxJg" rel="noopener noreferrer"&gt;Git Rebase Vs. Merge&lt;/a&gt;&lt;br&gt;
&lt;a href="https://education.github.com/git-cheat-sheet-education.pdf" rel="noopener noreferrer"&gt;Git Cheat Sheet&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>github</category>
      <category>merge</category>
      <category>rebase</category>
    </item>
    <item>
      <title>ActiveRecord Associations intro into 'has_many' </title>
      <dc:creator>AaronDski</dc:creator>
      <pubDate>Fri, 27 Aug 2021 14:59:10 +0000</pubDate>
      <link>https://dev.to/aarondski/activerecord-associations-intro-into-hasmany-m01</link>
      <guid>https://dev.to/aarondski/activerecord-associations-intro-into-hasmany-m01</guid>
      <description>&lt;p&gt;When learning about ActiveRecord in our coding bootcamp, they talked about the major benefits that ActiveRecord provides when working in Ruby and SQL. So I wanted to delve more into what is happening behind the scenes, and I discovered there is a &lt;em&gt;lot&lt;/em&gt; that ActiveRecord is doing back there. So let's talk about one that we all use: &lt;code&gt;has_many&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Has_many&lt;/code&gt; is one of the 6 types of associations (or "macro methods") that ActiveRecord offers. &lt;br&gt;
A &lt;code&gt;has_many&lt;/code&gt; association is similar to &lt;code&gt;has_one&lt;/code&gt;, but indicates a one-to-many connection with another model. You'll often find this association on the "other side" of a &lt;code&gt;belongs_to&lt;/code&gt; association. This association indicates that each instance of the model has zero or more instances of another model. With the &lt;code&gt;has_many&lt;/code&gt; association you will always want to make sure that whatever the model &lt;code&gt;has_many&lt;/code&gt; of, is plural. For example, in an application containing a child and their toys, the child model could be declared like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Child &amp;lt; ApplicationRecord
  has_many :toys
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A &lt;code&gt;has_many :through&lt;/code&gt; association is often used to set up a many-to-many connection with another model. This association indicates that the declaring model can be matched with zero or more instances of another model by proceeding through a third model. Also with the &lt;code&gt;has_many :through&lt;/code&gt; association, you will still want to make sure that whatever the model &lt;code&gt;has_many&lt;/code&gt; of is plural. For example, consider a game has reviews and users that can write reviews. The relevant many-to-many association declarations could look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Game &amp;lt; ApplicationRecord
  has_many :reviews
  has_many :users, through: :reviews
end

class Review &amp;lt; ApplicationRecord
  belongs_to :game
  belongs_to :user
end

class User &amp;lt; ApplicationRecord
  has_many :reviews
  has_many :games, through: :reviews
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Okay, now that we have that basic setup of what the &lt;code&gt;has_many&lt;/code&gt; table association can look like, lets get into what is auto-generated for you. Look at the list below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;others                            
others=(other,other,...)          
other_ids                         
other_ids=(id,id,...)             
others&amp;lt;&amp;lt;                          
others.push                       
others.concat                     
others.build(attributes={})       
others.create(attributes={})      
others.create!(attributes={})     
others.size                       
others.length                     
others.count                      
others.sum(*args)                 
others.empty?                     
others.clear                      
others.delete(other,other,...)    
others.delete_all                 
others.destroy(other,other,...)   
others.destroy_all                
others.find(*args)                
others.exists?                    
others.distinct                   
others.reset                      
others.reload     
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These auto-generated methods can and will save us a ton of time when querying any database. &lt;/p&gt;

&lt;p&gt;Here is another cool thing that &lt;code&gt;has_many&lt;/code&gt; can do: since associations are built from &lt;a href="https://api.rubyonrails.org/v6.1.4/classes/ActiveRecord/Relation.html"&gt;Relation&lt;/a&gt; objects, you can add conditions to the query, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Blog &amp;lt; ActiveRecord::Base
  has_many :published_posts, -&amp;gt; { where(published: true) }, class_name: 'Post'
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also read up on more of the capabilities that 'Association Methods' have, &lt;a href="https://api.rubyonrails.org/v6.1.4/classes/ActiveRecord/Associations/ClassMethods.html"&gt;Here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Furthermore, if you would like to learn more about the other five associations, here is a link with detailed documentation on those association types and their use cases &lt;a href="https://guides.rubyonrails.org/association_basics.html#the-has-many-association"&gt;ActiveRecord&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In conclusion, &lt;code&gt;has_many&lt;/code&gt; is a very helpful method that saves us a lot of time. I personally have made many methods not knowing that &lt;code&gt;has_many&lt;/code&gt; already provided said method. So it's a good thing to to be curious about whats happening or what the method is doing for you. post in the comments below about a time when a 'Macro' method saved you time. &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>ruby</category>
      <category>backend</category>
      <category>activerecord</category>
    </item>
    <item>
      <title>Intro Into Private Methods</title>
      <dc:creator>AaronDski</dc:creator>
      <pubDate>Fri, 13 Aug 2021 14:16:12 +0000</pubDate>
      <link>https://dev.to/aarondski/intro-into-private-methods-2jnb</link>
      <guid>https://dev.to/aarondski/intro-into-private-methods-2jnb</guid>
      <description>&lt;p&gt;The goal of this post is to shed some light on the topic of "Private Methods." This is a very basic overview on said topic, but I hope my findings will be enlightening, at least to some extent, for whomever views them. &lt;a href="https://www.rubyguides.com/2019/02/ruby-class/"&gt;Ruby Classes&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3resource.com/ruby/ruby-methods.php"&gt;Ruby Methods&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are reading this, then hopefully you already know what Classes and Methods are in &lt;em&gt;Ruby&lt;/em&gt;. If not, I recommend reading up on those topics before moving forward.&lt;/p&gt;

&lt;h6&gt;
  
  
  Public Vs Private
&lt;/h6&gt;

&lt;p&gt;&lt;code&gt;Private&lt;/code&gt; methods are really only to be used in the Class in which they reside. A good way for me to know when I would need &lt;code&gt;private&lt;/code&gt; methods is this: if I have a set of methods that do a specific task, and I don't want to alter that set or make it available outside the confines of this particular Class, then I would make it &lt;code&gt;private&lt;/code&gt;. I still have access to the info that those methods give me, but now anyone who reads my code would know that this distinct set of codes are designed to work together to perform a specific function. &lt;br&gt;
I like to think that &lt;code&gt;private&lt;/code&gt; methods are more "limited access" rather than "private" or "restricted," which just force you to follow proper channels, in order to get the information that the method provides.&lt;br&gt;&lt;br&gt;
&lt;code&gt;Private&lt;/code&gt; is not a keyword in &lt;em&gt;Ruby&lt;/em&gt; itself, but is actually a method that is already defined by the &lt;em&gt;Ruby&lt;/em&gt; language. &lt;code&gt;Private&lt;/code&gt; methods are only accessible by other methods from the same class, methods inherited from the parent class, and methods included from a module.&lt;/p&gt;

&lt;p&gt;A classic &lt;em&gt;Ruby&lt;/em&gt; method will start out as a &lt;code&gt;public&lt;/code&gt; method (easily accessible) by default and can be made &lt;code&gt;private&lt;/code&gt; very easily with these 3 different syntaxes, all of which accomplish the same result. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---6I7dA5l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kt2fyum7zqc4ys5re8tx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---6I7dA5l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kt2fyum7zqc4ys5re8tx.png" alt="Public"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  By adding &lt;code&gt;private&lt;/code&gt; in your code, &lt;em&gt;Ruby&lt;/em&gt; will read this and know to make all of the methods below &lt;code&gt;private&lt;/code&gt;
&lt;/h4&gt;

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

&lt;h4&gt;
  
  
  By using the &lt;code&gt;private&lt;/code&gt; method (“wrapper” syntax)
&lt;/h4&gt;

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

&lt;h4&gt;
  
  
  By using the &lt;code&gt;private&lt;/code&gt; method with explicit arguments
&lt;/h4&gt;

&lt;p&gt;Another variant of the syntax of &lt;code&gt;private&lt;/code&gt; methods is when we can explicitly pass method names as arguments.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JKe2b4sm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rlqrn4t6gjs8lwjz6za5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JKe2b4sm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rlqrn4t6gjs8lwjz6za5.png" alt="explicit arguments"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  You can make a also &lt;code&gt;private&lt;/code&gt; method &lt;code&gt;public&lt;/code&gt; again with this syntax
&lt;/h5&gt;

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

&lt;p&gt;Here's a metaphor that might help to better understand private methods:&lt;br&gt;
Imagine you go to your local coffee shop (think of this coffee shop as a &lt;em&gt;Ruby&lt;/em&gt; Class). The seat you choose, what you order, and waiting in line to place that order are all "public methods." Then your order is placed and the barista starts making your latte. From this point, you can think of the making of your latte as a "private method." You told the barista what you want, and now it's up to the barista, and you don't get a say in how the order is completed, it is simply made for you. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HSAdIXof--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hbloqkzqcg4kyg87ts00.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HSAdIXof--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hbloqkzqcg4kyg87ts00.png" alt="Coffee Shop Example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's say you want to just access &lt;code&gt;choose_milk&lt;/code&gt;. It won't let you, and you will get a "NoMethodError," which would look a bit like this in IRB:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9txfVd-6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdehq4cizsj00169e7ya.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9txfVd-6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdehq4cizsj00169e7ya.png" alt="NoMethodError"&gt;&lt;/a&gt;&lt;br&gt;
You can still get the information that &lt;code&gt;choose_milk&lt;/code&gt; provides, but you cannot break it up into just that one piece.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pg-o-8IC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdwb8v0r4aicb38eqzng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pg-o-8IC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdwb8v0r4aicb38eqzng.png" alt="make_drink"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See, you just need to go through the &lt;code&gt;make_drink&lt;/code&gt; method and then the information that &lt;code&gt;choose_milk&lt;/code&gt; provides is there.&lt;/p&gt;

&lt;p&gt;There you have it! This is what I have learned about &lt;code&gt;private&lt;/code&gt; methods, over the first week of coding in &lt;em&gt;Ruby.&lt;/em&gt; I hope that you found something useful in this article. Thank you for reading.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>ruby</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Decoding The Brain</title>
      <dc:creator>AaronDski</dc:creator>
      <pubDate>Thu, 22 Jul 2021 05:24:55 +0000</pubDate>
      <link>https://dev.to/aarondski/will-i-ever-learn-code-5619</link>
      <guid>https://dev.to/aarondski/will-i-ever-learn-code-5619</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclaimer I am not a Medical Professional. This information is my own deduction on how the brain functions, when we learn something new. Links to my sources are below.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Learning a new language can be more difficult than some people might realize. Or is it? There are a number of reasons, excuses and justifications that we all can use to avoid learning a new language... to say that, "it's just too hard." I, for one, am guilty of this unhealthy mindset. &lt;em&gt;Is this the way things are always going to be?&lt;/em&gt;, I thought, &lt;em&gt;Is there no way of escaping the fact that there are just some things I won't be great at (or even mediocre, by some standards)?&lt;/em&gt; I needed to know, and so I did some research.&lt;/p&gt;

&lt;p&gt;It turns out, when you try to learn something new--like skills, sports, languages, coding, etc--there are many things happening simultaneously in your brain. I'm going to point out a few that stuck out to me. &lt;/p&gt;

&lt;h2&gt;
  
  
  Neurons
&lt;/h2&gt;

&lt;p&gt;Neurons--you have around 85 billion of them. A neuron cell acts as a messenger, sending information in the form of nerve impulses (like electrical signals) to other neurons. This is how our brains access memories, operate our motor functions, and direct our speech, etc. So what does that mean when we are learning something new? Well, for everything that we already know, there are set pathways for our neurons to follow, but for things we &lt;em&gt;haven't&lt;/em&gt; previously learned, a pathway has not yet been created.&lt;/p&gt;

&lt;p&gt;This is the case when we don't know something: we "draw a blank" or just simply can't find the answer. In the event when we can come up with an educated guess or solution to something haven't learned, it is because our brains are trying to find a pattern or some common ground with something else we already know--a relative pathway for the information to move through. Say when you can't find a pathway, what does you brain do? It makes a new pathway, of course! You can think about making pathways like blazing a trail in a forest. Now we have a new pathway for the info to work with, but it's not that strong of a connection, (not a well-groomed, obvious trail). How do we make this connection stronger? Easy: use that pathway more. This is why repetition works so well to make things stick in your brain. Ever seen a cow trail? Same basic concept.&lt;/p&gt;

&lt;h2&gt;
  
  
  BLC (Bilingual Language Control)
&lt;/h2&gt;

&lt;p&gt;There has been a joint study on BLC done by Marco Calabria, Albert Costa, David W. Green, and Jubin Abutalebie. &lt;/p&gt;

&lt;p&gt;This BLC ability is now established as the architecture of what our brain is assessing when it decides what language to use. This complex system involves cortical and subcortical (different areas of the brain) structures, each responsible for particular cognitive processes, such as goal maintenance, conflict monitoring, interference suppression, and selective response inhibition. Our brain will separate the 2 languages, so that they don't interfere with each other. Switching between languages is very hard at first, but the more you do it the less taxing it becomes. It is incredible to think that, without our instruction or even awareness, our brain is able to switch to a completely different way of thinking, in a matter of nano seconds. &lt;/p&gt;

&lt;p&gt;I would surmise that this is applicable not only to spoken languages but to coding as well. Why not? They are "languages," after all. &lt;/p&gt;

&lt;h2&gt;
  
  
  Dopamine
&lt;/h2&gt;

&lt;p&gt;Dopamine is released in the brain when we do something that we enjoy; it's the chemical that makes us feel good. Simple enough. But what if we need to learn something that we &lt;em&gt;don't&lt;/em&gt; really enjoy, or that we don't even remotely like? Well it certainly makes it harder to listen to someone teaching on the topic. What if you had to learn that thing you had no interest in, but there was a large sum of money waiting for you once you had mastered the topic? Would you be more interested then? I know I would be. &lt;br&gt;
There is a very simple tactic we can use to motivate ourselves: set small objectives that can be achieved daily, which help to move you toward your desired destination. By doing this, we are not only establishing self-discipline, but we are creating miniature, daily "wins" by achieving goals, which makes us feel good (Dopamine), and produces motivation in us... and we may even then start to enjoy the topic or task at hand. (Disclaimer: there will always be subjects/projects that are not enjoyable). &lt;/p&gt;

&lt;p&gt;Dopamine is not only a great way to find things that we enjoy, but it is also a very helpful tool in the learning process. When there is more dopamine involved in your studying, your brain will find ways to reference those memories or thoughts, thus reinforcing what you just learned. So if you are on a topic that you don't particularly like, find a "carrot" to dangle in front of you. You will be amazed at what the brain is capable of, when it has a reason to learn.&lt;/p&gt;

&lt;h2&gt;
  
  
  Healthy Habits
&lt;/h2&gt;

&lt;p&gt;A.) Work well with others.&lt;br&gt;
Collaboration and collaborative learning have been a part of our human nature for as long as we know. We are inherently social beings and social learners. When collaborative learning techniques are used to support instruction, students tend to be more engaged, retain information better, and have better outcomes than those who prefer to be "solo learners."&lt;/p&gt;

&lt;p&gt;B.) Don't be stagnant.&lt;br&gt;
Be constantly learning new things, even if they are small things. When you learn, you are increasing/maintaining good and healthy neuroplasticity. In a way, our brains are like &lt;em&gt;Play-Doh.&lt;/em&gt; If you don't use your &lt;em&gt;Play-Doh,&lt;/em&gt; it gets hard and dried out. Our brains don't literally dry out, but you get the point. Use it frequently, or your brain will begin to lose functionality. &lt;/p&gt;

&lt;p&gt;C.) Rest.&lt;br&gt;
Good sleep is one of the (if not &lt;em&gt;the&lt;/em&gt;) greatest ways for your brain to replenish, re-energize, and heal. A tired brain can't accomplish much.&lt;br&gt;
Additionally, taking breaks is more beneficial than you might realize. Spacing out your study time with small breaks (15-20 minute beaks every 2-or-so hours of studying) is very helpful in not getting "burnt out," because your brain is able to "take a breather between legs of the race" (as it were).&lt;br&gt;
My hypothesis is that it gives the brain time to strengthen and consolidate the connections between your neurons, and sort through necessary information. &lt;/p&gt;

&lt;p&gt;This greater understanding of how your brain functions and the use of supportive learning strategies and can now allow you to help your brain to better learn!&lt;/p&gt;

&lt;p&gt;Side note: Stay hydrated! Maintain a consistent intake of water... trust me! Your brain will thank you.&lt;/p&gt;

&lt;p&gt;References&lt;/p&gt;

&lt;p&gt;BLC&lt;br&gt;
(&lt;a href="https://repositori.upf.edu/bitstream/handle/10230/44011/calabria_nyas_neur.pdf?sequence=1&amp;amp;isAllowed=y"&gt;https://repositori.upf.edu/bitstream/handle/10230/44011/calabria_nyas_neur.pdf?sequence=1&amp;amp;isAllowed=y&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Group Learning&lt;br&gt;
(&lt;a href="https://www.cs.cmu.edu/%7Ebmclaren/pubs/Wiley-ColaborativeLearningWhitePaper-2014.pdf"&gt;https://www.cs.cmu.edu/~bmclaren/pubs/Wiley-ColaborativeLearningWhitePaper-2014.pdf&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Healthy Practices&lt;br&gt;
(&lt;a href="https://www.powerofpositivity.com/researchers-explain-learn-something-new/"&gt;https://www.powerofpositivity.com/researchers-explain-learn-something-new/&lt;/a&gt;)&lt;br&gt;
(&lt;a href="https://kids.frontiersin.org/articles/10.3389/frym.2020.00054"&gt;https://kids.frontiersin.org/articles/10.3389/frym.2020.00054&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Learning Styles&lt;br&gt;
(&lt;a href="https://bau.edu/News/types-of-learning-styles/"&gt;https://bau.edu/News/types-of-learning-styles/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>learning</category>
      <category>mindset</category>
      <category>brainpower</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
