<?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 Derek Williams on Medium]]></title>
        <description><![CDATA[Stories by Derek Williams on Medium]]></description>
        <link>https://medium.com/@jogamer130?source=rss-b43e1716a4c1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*io-xUqC59DiUaSmb.</url>
            <title>Stories by Derek Williams on Medium</title>
            <link>https://medium.com/@jogamer130?source=rss-b43e1716a4c1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:32:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jogamer130/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[Attr_Nowhere]]></title>
            <link>https://medium.com/@jogamer130/attr-nowhere-f741344bc0fa?source=rss-b43e1716a4c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/f741344bc0fa</guid>
            <dc:creator><![CDATA[Derek Williams]]></dc:creator>
            <pubDate>Thu, 21 May 2020 06:59:44 GMT</pubDate>
            <atom:updated>2020-05-21T06:59:44.155Z</atom:updated>
            <content:encoded><![CDATA[<p>Attr_writer, attr_reader, and attr_accessor. Three important tools when wanting to write a method without the extra typing. When I first came across these methods, I wasn&#39;t quite sure how to use or view them. Originally, my mind wanted to leave it in the “weird ruby stuff” category and just do things the normal way. But after realizing that there are many good times to use it I started to force myself to just do it the “right” way. With time, this way will hopefully feel like the right way sooner, rather than later.</p><h3>Attr_reader</h3><p>Let&#39;s say you have an instance that you want to be seen, you could write it like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*31I9yf2XeKHXftoWFHTQGw.png" /></figure><p>However, if you ever wanted to do the same thing, but with a little more control AND shorten your code at the same time. In this case, if we wanted to be able to view the name but never change it, we would have to use the attr_reader as shown below:</p><pre>class Friend</pre><pre>attr_reader :name</pre><pre> def initialize(name)</pre><pre>  @name = name</pre><pre> end</pre><pre>end</pre><pre>Dave = Friend.new(&quot;Dave Smith&quot;)</pre><pre>puts dave.name <em>#=&gt; Dave Smith</em></pre><p>This is known as a getter method, obviously because it GETS and READS the information. The really important part to remember is that this reads the data but can’t write it or alter the data.</p><h3>Attr_writer</h3><p>This one from what I have seen is less likely to be used. It’s not that it’s useless but that I have yet to see many times in which it can be applied. This method is known as a <strong>setter</strong>, and it can write data but it can not show it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*JiOjq3a_M5NG1wMA8Nigsg.png" /></figure><p>As you can see here, line 13 changes the original variable to say “kelly” instead of “Dave Smith”. the writer line allowed for it to change the data of the variable and not only read it. However, is this still the best way to write this code?</p><h3>Attr_accessor</h3><p>Why take the time, to write two methods every time you want to be able to see and change something. Its a very normal need, which is why attr_accessor is helpful! This makes it easier to clean up the code and have one instance in one method, instead of assigning it to two different ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*IzUbTJNo6RJYakjtvloAgA.png" /></figure><p>This is just like the code above, however, using attr_accessor I am able to do the jobs of both the setter and the getter without having to write them both. It’s simply a quick and easy way of getting code done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*YVsZFtOJu_Vco2ea" /></figure><p>So even though, I started this off with feeling like all of these methods were awkward and forced, after really looking at how they work and how they can be used, I understand why they’re needed. I can finally feel like I’m still writing normal ruby code and not some random line of code that does a “thing” I can’t explain. I can set, I can get, and I can do both, with a simple and easy line of code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f741344bc0fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get vs Post]]></title>
            <link>https://medium.com/@jogamer130/get-vs-post-e695a4f8f791?source=rss-b43e1716a4c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e695a4f8f791</guid>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Derek Williams]]></dc:creator>
            <pubDate>Sun, 23 Jul 2017 19:12:43 GMT</pubDate>
            <atom:updated>2017-07-23T19:25:21.607Z</atom:updated>
            <content:encoded><![CDATA[<p>I want to write a web site and I need to make sure that it follows the restful rules. But how do I know when to use Get or Post? It’s actually quite simple.</p><p>To start, you must know what you are trying to do. Before throwing in random options(get, post, delete), make sure you THINK about what your end goal is. With this in mind began your line of code.</p><pre>get &quot;/test&quot; =&gt; &quot;example#index&quot;</pre><p>We’ll start with get since that tends to go first. Get is used when you are trying to just write something on a regular page, that doesn’t do anything but show people some text or maybe an image. This is the most common of the two and most used.</p><pre>post &quot;/test&quot; =&gt; &quot;example#create&quot;</pre><p>Next, we will talk post. Post is only used when trying to send something out. Such as a New Profile. maybe you want to have someone sign up and send their profile to your database or send them to another page. Using the post will enable you to do so. But when ever there is a post, there is a get, so it’s less of a vs as much as it is a mutual agreement.</p><p>In the end, both get and post works well together to make an awesome web site, sometimes using things outside of the restful ways, is best.</p><pre>get &quot;example&quot; =&gt; &quot;test#index&quot;</pre><pre>get &quot;example&quot; =&gt; &quot;test#index&quot;<br>  get &quot;example/new&quot; =&gt; &quot;test#new&quot;<br>  post &quot;example&quot; =&gt; &quot;test#create&quot;<br>  get &quot;example/:id&quot; =&gt; &quot;test#show&quot;<br>  get &quot;example/:id/edit&quot; =&gt; &quot;test#edit&quot;</pre><pre>get &quot;example_search&quot; =&gt; &quot;test#search&quot;</pre><pre>get &quot;/signup&quot; =&gt; &quot;users#new&quot;<br>  post &quot;/users&quot; =&gt; &quot;users#create&quot;</pre><pre>get &quot;/login&quot; =&gt; &quot;sessions#new&quot;<br>  post &quot;/login&quot; =&gt; &quot;sessions#create&quot;<br>  get &quot;/logout&quot; =&gt; &quot;sessions#destroy&quot;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e695a4f8f791" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terminal Time Travel!]]></title>
            <link>https://medium.com/@jogamer130/going-back-in-the-terminal-305a7c7403e0?source=rss-b43e1716a4c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/305a7c7403e0</guid>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Derek Williams]]></dc:creator>
            <pubDate>Sun, 02 Jul 2017 19:21:44 GMT</pubDate>
            <atom:updated>2017-07-23T19:10:57.372Z</atom:updated>
            <content:encoded><![CDATA[<p>Many times when you in the terminal you may want to go back to a file without having to quit the terminal altogether. With this helpful tool, you won’t have to worry about that anymore. Here’s how you do it.</p><ul><li>First, you find out how far back you need to go. Depending on this, you may have to write more code than before. But don’t worry, either way, this less than two lines to write.</li><li>Once you know how far you want to go the type:</li></ul><pre>cd ..</pre><p>This only goes back one file, but if you would like to go back more this is how:</p><pre>cd ../.. #this goes back two. add more dots to go back more.<br>cd ../../.. etc.</pre><ul><li>And it is as simple as that. With this new tool, you won’t have to worry about going into the wrong folder or file with no way back.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*YPaLGI5h8mutsl2wKeFU5Q.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=305a7c7403e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>