<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.2.0">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2021-03-14T23:26:36+00:00</updated><id>/feed.xml</id><title type="html">Ruby Cat Farm</title><subtitle>Learn how to make web applications with Ruby on Rails by helping cats run a farm.</subtitle><entry><title type="html">Let’s learn some HTML</title><link href="/html/2021/03/02/lets-learn-some-html.html" rel="alternate" type="text/html" title="Let’s learn some HTML" /><published>2021-03-02T22:51:34+00:00</published><updated>2021-03-02T22:51:34+00:00</updated><id>/html/2021/03/02/lets-learn-some-html</id><content type="html" xml:base="/html/2021/03/02/lets-learn-some-html.html">&lt;p&gt;Cats are not very fastidious record keepers by default, so they never know how many carrots they have planted. Or harvested. Or really what they’ve planted at all.&lt;/p&gt;

&lt;p&gt;You figure that you should make a website for the cats to help keep their farm records in order. They’ve got a computer that they share in the house, and they’ve all got smart phones. They’ve vowed not to discuss iOS vs Android ever again, as they’ve only recently finished healing from the last skirmish.&lt;/p&gt;

&lt;p&gt;The basic building blocks for a webpage are made using HTML. That stands for Hypertext Markup Language, if you care. It sounds very futuristic, but it’s really just a way to tell web browsers what the text we’re sending them means. We’ll just cover a bit here to introduce the concepts and get into more as we need to later on.&lt;/p&gt;

&lt;h2 id=&quot;paragraphs&quot;&gt;Paragraphs&lt;/h2&gt;

&lt;p&gt;Here’s an example:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is a paragraph.&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That p tag tells the browser “hey, this is a paragraph.” Note the slash inside the second one – this marks the end of the paragraph.&lt;/p&gt;

&lt;h2 id=&quot;links&quot;&gt;Links&lt;/h2&gt;

&lt;p&gt;Another important tag is for making links. Links are also called anchors, which is important only because otherwise it’d be very confusing that it’s an a tag:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;href=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;https://rubycat.farm&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Ruby Cat Farm Rules&lt;span class=&quot;nt&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;It might still be confusing. But don’t fret.&lt;/p&gt;

&lt;p&gt;This bit of HTML makes a link to https://rubycat.farm with the text “Ruby Cat Farm Rules”.&lt;/p&gt;

&lt;p&gt;“What is that href thing?”, you ask. Fair question. It stands for hypertext reference.&lt;/p&gt;

&lt;p&gt;What, that’s not helpful? Basically it tells the browser where to link. It is an attribute of the a tag.&lt;/p&gt;

&lt;p&gt;The original creators of HTML lived in a different time (1990) and were super nerds.&lt;/p&gt;

&lt;h2 id=&quot;pictures&quot;&gt;Pictures&lt;/h2&gt;

&lt;p&gt;Another important tag to know is for including pictures on a page. Not all the cats can read very well, and we want them to know what’s going on.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/carrots.png&quot; alt=&quot;Lovely bunch of carrots&quot; /&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;img&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;carrots.png&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;alt=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Lovely bunch of carrots&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The tag name for pictures at least makes sense – img for image. The src attribute points to the file for the image to include. The alt attribute allows an “alternate” value for the image. This is useful for screen readers so cats who can’t see very well can still know what’s in the image.&lt;/p&gt;

&lt;h2 id=&quot;divs&quot;&gt;Divs&lt;/h2&gt;

&lt;p&gt;A &amp;lt;div&amp;gt; tag doesn’t do much. It stands for “division” and is just used to wrap distinct blocks of content, so you can use it to wrap different sections of content. For example:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  This is one section.
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  This is another section.
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;lists&quot;&gt;Lists&lt;/h2&gt;

&lt;p&gt;There are two types of lists: ordered lists and unordered lists. If it’s an ordered list, it’ll get a number before each item. If it’s an unordered list, it’ll get a bullet (y’know, a circle). Here are some examples:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Bulleted item one&lt;span class=&quot;nt&quot;&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Bulleted item two&lt;span class=&quot;nt&quot;&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;ol&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Ordered item one&lt;span class=&quot;nt&quot;&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Ordered item two&lt;span class=&quot;nt&quot;&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/ol&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;When viewed in the browser, that looks like:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/lists.png&quot; alt=&quot;Lists&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Delightful! The abbreviation for ordered list (ol), unordered list (ul), and list item (li) actually make sense.&lt;/p&gt;

&lt;h2 id=&quot;the-whole-document&quot;&gt;The whole document&lt;/h2&gt;

&lt;p&gt;The basic layout for every HTML page looks looks this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;This goes in the title bar&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Content goes in the body while information about the page generally goes in the head&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Everything’s wrapped in an html tag – that tells the browser “hey, this stuff is HTML”. Inside that, there’s a head section and a body section. The head stuff is sort of information about the page. The title is what you see up in the tab for for a webpage. The body contains the actual content of the page.&lt;/p&gt;

&lt;h2 id=&quot;okay-now-lets-see-it&quot;&gt;Okay, now let’s see it!&lt;/h2&gt;

&lt;p&gt;If you put that in a text editor, save it as for_the_cats.html. Double click the file and it should open in your favorite web browser, and then revel in the glory of your first webpage. Great success.&lt;/p&gt;

&lt;p&gt;Go ahead and try adding some of the other elements talked about in this chapter. Play around! Have fun!&lt;/p&gt;</content><author><name></name></author><category term="html" /><summary type="html">Cats are not very fastidious record keepers by default, so they never know how many carrots they have planted. Or harvested. Or really what they’ve planted at all.</summary></entry><entry><title type="html">So what is a cat farm, anyway?</title><link href="/intro/2021/03/01/so-what-is-a-cat-farm-anyway.html" rel="alternate" type="text/html" title="So what is a cat farm, anyway?" /><published>2021-03-01T22:51:34+00:00</published><updated>2021-03-01T22:51:34+00:00</updated><id>/intro/2021/03/01/so-what-is-a-cat-farm-anyway</id><content type="html" xml:base="/intro/2021/03/01/so-what-is-a-cat-farm-anyway.html">&lt;p&gt;Well. Close your eyes. Actually, don’t – we wouldn’t get any further. But imagine with me a small farmhouse atop a lovely verdant hill with fields of vegetables in the valley just below us. Chickens and horses meander around, making their appropriate noises.&lt;/p&gt;

&lt;p&gt;All around and over the house and fields below are cats. The cats are all hard at work. Mostly. As their attention allows. Many are plucking vegetables out of the ground. Others are plantings seeds. Some are napping under the nearby weeping willow tree. Okay, most are napping under the tree.&lt;/p&gt;

&lt;p&gt;This is the cat farm. It’s all run by cats. Those that can keep their eyes open. Don’t tell the humans in the nearby town of Smog. They cannot be trusted. They’ve grown quite jealous of the cats’ ability to harvest as many crops as they do while still getting fifteen hours of sleep a day.&lt;/p&gt;

&lt;p&gt;The cats, however, keep having kittens. It’s truly incredible how much those babies can eat. The cats need to harvest more. They’ve done wonders with absolutely no organization, but they would be be absolutely spectacular with some level of coordination and record keeping. And the kits get to keep eating, and they very much like eating.&lt;/p&gt;

&lt;p&gt;You are to be the guardian of the cat farm. Of the kittens. Please don’t let them go hungry.&lt;/p&gt;

&lt;p&gt;The cats are not the most process-oriented of creatures. They forget how many vegetables they’ve planted. They get distracted by climbing up – and napping under – their beautiful tree, and suddenly they’ve forgotten how many carrots they have.&lt;/p&gt;

&lt;p&gt;You need to help them. They need their naps.&lt;/p&gt;

&lt;p&gt;You are going to write some software to help them run the farm smoothly. If everything is recorded, forgetfulness isn’t an issue. Then they know just how hard they have to work before it’s nap-time.&lt;/p&gt;

&lt;p&gt;We’ll be using Ruby on Rails 6 to build a website to help these cats run an efficient farm. They can’t change who they are, so let’s help them out.&lt;/p&gt;

&lt;p&gt;We’ll start by looking at some fundamental technologies that make the web work and then ease into Ruby before jumping into Ruby on Rails, which is a powerful framework that ties it all together. We’ll get the cats more efficient in no time.&lt;/p&gt;</content><author><name></name></author><category term="intro" /><summary type="html">Well. Close your eyes. Actually, don’t – we wouldn’t get any further. But imagine with me a small farmhouse atop a lovely verdant hill with fields of vegetables in the valley just below us. Chickens and horses meander around, making their appropriate noises.</summary></entry></feed>