<?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[gSchool Stories - Medium]]></title>
        <description><![CDATA[A collection of posts from gSchoolers - Medium]]></description>
        <link>https://medium.com/gschool-chronicles?source=rss----3790907c0b23---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>gSchool Stories - Medium</title>
            <link>https://medium.com/gschool-chronicles?source=rss----3790907c0b23---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:58:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/gschool-chronicles" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Advice to Future and Present gSchoolers]]></title>
            <link>https://medium.com/gschool-chronicles/advice-to-future-and-present-gschoolers-5232e7577720?source=rss----3790907c0b23---4</link>
            <guid isPermaLink="false">https://medium.com/p/5232e7577720</guid>
            <dc:creator><![CDATA[David Middleton]]></dc:creator>
            <pubDate>Mon, 13 Apr 2015 21:57:01 GMT</pubDate>
            <atom:updated>2015-04-17T22:16:28.638Z</atom:updated>
            <content:encoded><![CDATA[<p>Advice to Future and Present gSchoolers</p><p>I’m a gSchool graduate ten days out of the full stack development program. It was an amazing six months that I will never forget. I’m very excited to continue interviewing for developer, QA, and DevOps positions and find my first job in tech with the skills I gained through gSchool. (#devforhire)</p><p>In a short six months I had an amazing transformative experience in my approach to problem solving, learning to code, and allowing myself to have fun writing code with my own custom workflow.</p><p>If I had to do it all over again, this is the advice I would give myself.</p><ol><li>Take Care of Yourself</li></ol><p>The days where I was well rested (or amply caffeinated) were the days that I was able to retain the most information and have the most fun learning.</p><p>This includes eating healthy and finding time to exercise. A healthy lifestyle in and outside of gSchool will drastically change your experience for the better. I was working out three times a week prior to gSchool and felt the need to stop that routine in order to learn as much information and knowledge about Ruby on Rails as I could. What I failed to realize is that lifting is a meditative happy place and a great stress reliever. After I started to actively lift again about midway through gSchool I felt a higher level of mental clarity in class and a greater ability to disconnect from my work.</p><p>2. Take Good Breaks</p><p>One of the hardest things for me to do was to disconnect myself from the stories I had remaining for my big projects. I’d close my laptop but my brain would still be rattling around with ideas of how to fix a complicated bug in my application or I would be telling myself, “You should know this!”.</p><p>The best solution that I found is to close my laptop and go for a walk. It took me a while to figure this one out but the sooner you find your disconnect the better. For some it might be reading a book or calling a friend on the phone. Do anything that engages you mentally so that it is impossible for you to think about the work you have remaining. You will come back to your code refreshed and it will make a world of difference.</p><p>3. Have Fun</p><p>Is learning to code always fun? Not all the time. Can you do something about it? I did and I know you can too.</p><p>There were too many days when I walked into class and forgot to have fun. I was too frustrated with myself, the code, or feeling behind that I let it hurt my mindset and make my day more difficult. The days where I made a conscious effort to enjoy the small victories and told myself to have fun were the days where I left class feeling more accomplished than defeated and eager to learn more.</p><p>The code and frameworks you are learning are complex, awesome, and learning them is something you love to do. You wouldn’t have made the sacrifices to join gSchool and participate in a very fast paced learning environment if you felt differently.</p><p>Treat the errors and bugs you will continually receive through class like quests or monsters in a video game to overcome and not as a roadblock preventing you from learning. Running into problems and overcoming them calmly and with a smile on your face is what will make you a great developer that everyone will enjoy working with.</p><p>Thanks for reading and happy coding everyone!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5232e7577720" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gschool-chronicles/advice-to-future-and-present-gschoolers-5232e7577720">Advice to Future and Present gSchoolers</a> was originally published in <a href="https://medium.com/gschool-chronicles">gSchool Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Collection Select with Ember.js & Rails API]]></title>
            <link>https://medium.com/gschool-chronicles/collection-select-with-ember-js-rails-api-17c9f50ea1e9?source=rss----3790907c0b23---4</link>
            <guid isPermaLink="false">https://medium.com/p/17c9f50ea1e9</guid>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[ember]]></category>
            <category><![CDATA[how-to]]></category>
            <dc:creator><![CDATA[Beth Jaswa]]></dc:creator>
            <pubDate>Thu, 19 Feb 2015 05:15:55 GMT</pubDate>
            <atom:updated>2015-05-12T01:46:03.305Z</atom:updated>
            <content:encoded><![CDATA[<p>Searching for Ember help has been tough, so I feel the need to share my struggles and add to the resources available. Between the docs, a blog, and some Stack Overflows, I finally got it working.</p><p>I’ve done several forms in Rails and collection select was no big deal. You just follow the pattern and everything works. What I would’ve given for a little User.all in my handlebars today!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*1XFOXFsBmdSHO0PMXl0WEw.png" /></figure><h3>Back Story</h3><p>I have a <a href="http://jaswa-blog.herokuapp.com/">blog app</a> using Ember and a Rails API that I’ve built. I seeded my API database so I have posts, which belong to a user, and related comments (which also belong to a user). This allowed me to set up the Ember side without worrying about create, update, or destroy actions. Just the simple stuff of index and show. Mission achieved. But now I want to create a new post and have a user associated with it. No one wants a post with a user_id of null. Boring.</p><h3>The Quest Begins</h3><p>I started with the Ember <a href="http://emberjs.com/api/classes/Ember.Select.html">docs</a> and was able to basically hardcode my user objects within an array in my controller, but that’s not sustainable. I knew I needed to ask the store to find all my users and to get that done when the page loaded, but I couldn’t get it to work. I tried asking the store within the controller. I tried setting my model to get my users in the route. You name it, I probably tried it. Sometimes I wish my computer would save each failing attempt so after I finally solve it I could see how close or far off my attempts were.</p><p>Here’s the template for a new comment. The syntax for the select comes mostly from the docs and I also found the prompt part around on the internets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*1EW-sZqjuvyafEg01BEW0g.png" /><figcaption>Template file for a new comment</figcaption></figure><p>I hung out on Stack Overflow and then I finally dug up this <a href="http://blog.isnorcreative.com/2014/07/29/ember-select-for-association-with-selected-option.html">blog</a> post. This was the missing piece at last! In my route file, I needed to use a setupController function which sets two things up for my controller: the model and users. This is where I finally ask the store to find all my user objects and return them to me so they are available in my template!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*5BCvraWLrigudCXPFzXdSA.png" /><figcaption>Route file for a new comment</figcaption></figure><h3>Success!</h3><p>This did produce the drop down list for me, but user_id still wasn’t getting saved and I got a big old null in my face. I was even able to get the user_id out on the console from newComment action, but still null in the database (at this point I already set my Rails controller up to accept new comments).</p><h3>But, Wait— There’s More!</h3><p>In Rails, I simply needed to have my associations done correctly and then save the related id. In Ember not so much. I already knew I had my associations done correctly from my seeded data, so that wasn’t the problem. Apparently in Ember you need to give Ember the whole related object, not just its id in order for the store to save. How do you get the entire user object? You bet- you ask the store!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*acMz3DFRo4crPhKmm7VJyA.png" /><figcaption>Controller with newComment action</figcaption></figure><p>The amount of binding this’s started to get out of hand, so I created a variable to point to the controller. I also created a variable for body and set it equal to content of the body on the template. Now the magic starts to happen. The long and short of the top half is that I asked the store for the post and user objects based on the template and then to create a record in the store for a comment with each key equaling its content.</p><p>Next the code will save the comment. Then it will transition back to the post page and display a flash message of success. Finally the controller will reset bodyCopy back to empty.</p><p>Whew! It finally works! Then of course I implemented this on for new posts as well. And yes the functionality of it is a bit strange because actually you’d want to have users log in and then whatever they write a comment or post that it is associated with them. However right now, I don’t know how to do that and this at least solves my problem of null user_ids.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17c9f50ea1e9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gschool-chronicles/collection-select-with-ember-js-rails-api-17c9f50ea1e9">Collection Select with Ember.js &amp; Rails API</a> was originally published in <a href="https://medium.com/gschool-chronicles">gSchool Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Search Bar Madness: a How-To for Ember.js]]></title>
            <link>https://medium.com/gschool-chronicles/search-bar-madness-27f98e1d0654?source=rss----3790907c0b23---4</link>
            <guid isPermaLink="false">https://medium.com/p/27f98e1d0654</guid>
            <category><![CDATA[ember]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[search]]></category>
            <dc:creator><![CDATA[Beth Jaswa]]></dc:creator>
            <pubDate>Fri, 06 Feb 2015 00:58:20 GMT</pubDate>
            <atom:updated>2017-05-05T15:05:58.071Z</atom:updated>
            <content:encoded><![CDATA[<p>In an effort to understand how to add a search bar to my Ember app (a class project), I’ve compiled something that I wish I had when I was struggling to set it up. It might not be in the most logical order since I am writing this after I’ve figured it out.</p><p>For this example, it assumes that in the router you have a search route nested under the posts route.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*KDLVV-r8JYtI1XnmIwfJ-w.png" /></figure><h4>Add the Physical Search Bar to the Template</h4><pre>{{input type=”text” class=”search” placeholder=”Search” value=search action=”queryPost”}}</pre><p>In my case, I added it to my posts.hbs because I wanted the search on my side bar. Therefore the action needs to be added to the posts controller.</p><h4>Add a queryPost Action</h4><p>This action is run when you hit enter to search. I created a variable called query which is set to the search bar’s value. Then I want to transition to a search template and pass queryParams with a value of the hash {term: query}. The user should be able to enter in a word to the search bar. Hit enter on their keyboard which will trigger the queryPost action which will fetch search bar’s value and set it to query. Then the user will transition (like a redirect in Rails) to the search template and pass in the value of term to whatever query is.</p><pre>queryPost: function() { var query = this.get(‘search’); this.transitionToRoute(‘posts.search’, {queryParams: {term: query}}); }</pre><h4>Create a Template for the Search Results</h4><p>I decided to have a sentence that would restate what was inputed into the search bar. Then I iterated over each post in the model to display the title and body of posts. Originally this just displayed all posts which is fine for now.</p><h4>Create a Controller</h4><p>Next I gave the search controller queryParams with a value of [‘term’]. Then gave the controller term with a value of null.</p><h4>Create a Route</h4><p>Next I added a search route and a model within that. The model function accepts params and says if the params have a key of term, then it will return what the store finds that matches the term. Otherwise it will return an empty array so nothing will get searched.</p><pre>return this.store.find(‘post’, {find: params.term});</pre><h4>Test the Rails API without Ember</h4><p>Use <a href="https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en">Postman</a> to see the json that’s rendered from your index action. Enter a request url as a GET request.</p><blockquote>http://localhost:3000/posts?find=A</blockquote><p>This should return an empty array of posts.</p><h4>Your Rails Posts_Controller</h4><p>Next I added some logic and queried the database. So in sudo code: If params with a key of find, then filter all posts where title equals the value of find. Otherwise render the normal json for all the notes. At first I just hardcoded title: “A” because I had a title of “A”, then I changed it to equal the value. This doesn’t work like a normal search bar yet. Right now it should only return the post if you search an exact title.</p><p>Once that works — check with Postman and in your Ember app — then update the database query to work how you’d expect it to. Disclaimer: I’m using SQLite as my database. Now update the query to SQL and something like this:</p><pre>Post.where(&quot;title like ? OR body like ?&quot;, &quot;%#{ some_variable }%&quot;, &quot;%#{ some_variable }%&quot;)</pre><p>some_variable will be the value of the find key (let’s call the value <strong>input</strong> for this example) will read like this:</p><p>Find the posts WHERE title is LIKE <strong>input</strong> OR body is LIKE <strong>input</strong>. The % surrounding some_variable allows it to search within body or title for that given word.</p><p>Make sure to render json: results_of_your_query</p><p>Test it out. Embrace Mr. Postman. Double check the Rails server in the console to make sure it’s happy. If that’s all good, then try it in your Ember app.</p><h4>But wait? I have this bug where I search for x and then want to search for y and it doesn’t ever search for y but the path changes!</h4><p>Well at least you know the problem isn’t in your Rails API because Postman returned different posts for different search results.</p><p>Let’s jump back into the search controller. Term is initially null. After we search for something, term is changed to whatever word we searched. Now we need to be able to change term’s value again to the next word that we search.</p><p>Handlebars.js doesn’t allow you have functions in a template, so instead we’ll write the function in the search controller and refer to it in the view/template. I wrote a function called results that returns what the Store finds within the post model and sets the value to the find key to this’s term value. Then it will change the value property of term. It looks like this:</p><pre>results: function () { return this.store.find(‘post’, {find: this.get(‘term’)}); }.property(‘term’)</pre><p>Then go back to your template and update your each loop to look for post in results instead of post in model. Now it will only display the latest search results as you would expect!</p><p>Turns out now I don’t need what I wrote in the search route model. I actually don’t need any of it. Between the results function and setting term to null, term will return an empty array if given no search term and then will reset term for each search result.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27f98e1d0654" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gschool-chronicles/search-bar-madness-27f98e1d0654">Search Bar Madness: a How-To for Ember.js</a> was originally published in <a href="https://medium.com/gschool-chronicles">gSchool Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing… Colorado Wine Tracker!]]></title>
            <link>https://medium.com/gschool-chronicles/introducing-colorado-wine-tracker-a2006ad18171?source=rss----3790907c0b23---4</link>
            <guid isPermaLink="false">https://medium.com/p/a2006ad18171</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[wine]]></category>
            <dc:creator><![CDATA[Beth Jaswa]]></dc:creator>
            <pubDate>Fri, 30 Jan 2015 03:15:30 GMT</pubDate>
            <atom:updated>2015-05-12T01:43:35.320Z</atom:updated>
            <content:encoded><![CDATA[<h2>Introducing…</h2><h2>Colorado Wine Tracker!</h2><p>I’ve been working on a Rails app for the past few months as my personal project for gSchool and I’m finally happy enough with it to share! For friends and family not interested in the details of how it works, stay tuned — I’ll have a post for you soon.</p><h3>Background</h3><p><a href="http://wine-tracker.co/">Colorado Wine Tracker</a> started out as a simple idea to track my tasting notes for various wines. I love wine and despite several systems, I am horrible at remembering what I actually liked and what I didn’t. Other tracking systems seemed too complicated or not complicated enough and I never kept up with any of them. And then my Wine Tracker was born!</p><p>For the sake of simplicity, I decided to narrow my scope to only Colorado wines. This way I could have a public section of the site listing Colorado wineries’ contact information and wines as well as a private section for individual tasting notes. I also didn’t want the user to input the wine and winery information each time as other systems required because the whole input process seemed to take too long.</p><h3>Features</h3><h4>Informative How to Taste Wine</h4><p>This page teaches the public how to taste wine with possible options and is the basis for the tasting note form.</p><h4>Colorado Wineries</h4><p>I’m very proud of the the winery index and show pages. It’s been fun to decide where the data for these pages should come from and how to retrieve it. My main goal has always been to populate my database or site and have an option for members or admins to add new wineries.</p><p><strong>Yelp API gem</strong></p><p>Initially, I decided to pull information from Yelp’s API and since my project is built in Rails I installed the Yelp API gem. I read the docs and display requirements and was concerned because Yelp’s instructions explicitly state that you can’t save their data or have automated calls to their API. Both of which I was planning to do. Out of interest to learn how to do it — I did it anyway and then figured out a better way for the future.</p><p>In order to borrow Yelp’s data, I created a rake task that pulled in the API and searched for wineries. Then I iterated over each business and created a hash with my database fields as the keys and Yelp’s fields as the values. Then I instantiated a new winery, passed my hash to it, and saved. Bam! I’ve got wineries!</p><p>Well it turns out Yelp doesn’t have that many Colorado wineries in their database and I didn’t just didn’t feel right about doing storing their data, so I searched for a new source of wineries. After I found a new data source, I deleted the wineries that used Yelp’s data and updated the rake task to only store Yelp’s id. The task pulls the API in, then checks my database against the API’s info. If the winery name matches, it will store the Yelp id, but otherwise it will create a new winery with only that property filled in. This allows the admin to see new wineries from Yelp and decide to approve them or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v7f8Zb467LmO3hqki9SsYA.png" /><figcaption><strong>Changed my rake task to now only store Yelp’s id if my data’s and Yelp’s names match, otherwise create a new winery with that yelp_id.</strong></figcaption></figure><p><strong>Scraping ColoradoWine.com</strong></p><p>Finding a site with a good collection of data proved to be a bit challenging and then even more so after I picked a site to scrape. <a href="http://www.coloradowine.com/">ColoradoWine.com</a> provides a comprehensive list of wineries with their contact info, hours, and other great info — so perfect! Except not really.</p><p>I went the Nokogiri gem route and tried to use the CSS classes to get down to the information I needed, but I couldn’t quite get what I wanted. Turns out there’s a distdata.cfm file loaded within the site that has one huge array with all the information I needed. Later in the file, it shows that there are 42 fields for each winery. I copied the array and created a file in my app so that I could start to work with it. (Understandably this is not the best way to go about what I wanted, however it got the job done and I only needed to pull the info once.) In my rake task, I took that array and using the .each_slice method I was able to take the array and separate it into a new array for each 42 items. Then I created a hash with my fields as the keys and the new array’s data with as the values. The data from ColoradoWine included wineries, restaurants, bars, and liquor stores in their data, but I just wanted to pull the wineries. If the data’s types field is “Winery”, then I inserted that information into my winery_array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*ljP6B0I-LjwDwgdtmGlwsA.png" /><figcaption><strong>Pulling relevant info from ColoradoWine’s file</strong></figcaption></figure><p>I saved that array into wineries_cleanedup.rb and set it to the instance variable @cowineries so I could call it in my rake task. Just from briefly looking at the data, I knew some of it wasn’t any good so I went through it and cleaned it up. Then I set a new rake task to load the wineries to the database. I iterated over each winery and imported them into my database much like I did with Yelp’s info.</p><p>After populating my database, my winery index and show pages look so much better!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*ELIe9oDbDcMUSfj8dQxy_Q.png" /><figcaption><strong>Winery index</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gde6WbHAueDqxSc6pjEnqA.png" /><figcaption><strong>Winery show page displaying Yelp API’s rating, number of reviews, and yelp site</strong></figcaption></figure><h4>Colorado Wines</h4><p>Currently the only way to populate the wine index page is from user input so it will continue to grow over time. The public does have access to see a list of wines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*Gyz8Wy8A7wVgTnLB4AO1pg.png" /><figcaption><strong>Wine index as an Admin</strong></figcaption></figure><p>Wines belong to a winery and therefore wines have a winery_id property. In order to display the winery name for a given wine, I did the following within an each loop over wines:</p><blockquote>Winery.where(id: wine.winery_id).pluck(:name).join()</blockquote><p>Then I also did a similar statement to pull the winery.id so I could appropriately link to a given winery to it’s name on this page. This page will also display wine rating from members’ tasting notes.</p><h4>Speaking of Associations: Wine Tracker has many!</h4><p>Building this app has been very enjoyable because before I was able to hit rails new, I needed to decide how I was going to structure my database. A few UML diagrams later, I decided a few associations:</p><ul><li>Wineries have many wines.</li><li>Wines have many tasting notes. A wine belongs to a winery.</li><li>Users have many tasting notes.</li><li>A tasting note belongs to a user and also belongs to a wine.</li></ul><h4>User Authorization &amp; Controller Specs</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*fX7uGteHcehXPnvY4ZXj3A.png" /><figcaption>User auth in 3 methods!</figcaption></figure><p>When I added user authorization, I decided to write my controller specs first and it was worth every bit of time spent on my tests. I essentially set up a big before action to create various users using object creation methods that I defined within in my specs folder. Then I wrote a test for each possibility for each action as if my methods were there. I watched my tests fail and pass as I expected before I added user authorization. Then I skipped all failing tests. As I worked through user auth, I un-skipped the tests related to the method I was writing. It was pretty amazing to run my tests and instantly tell if my method was working as expected or not. RSpec for the win!</p><h4>Once you’re a member</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NwdlZHtn02xBOJhp4123lA.png" /><figcaption><strong>Notice that members can upload photos and that several fields offer options for the member to choose</strong></figcaption></figure><p>I did basic CRUD several times and became a pretty comfortable with forms and Bootstrap’s stylings. Once you’re logged in (a member), you can add new wines and wineries to the database. You can see and update your own user information. You can also create your own tasting notes that are kept private. Only the wine rating on your tasting note will be compiled into the overall rating for that wine.</p><p><strong>Carrierwave, Fog, and AWS</strong></p><p>Wines and wineries both have the option to upload an image to the database. In order to add this feature, I needed to install the <a href="https://github.com/carrierwaveuploader/carrierwave">carrierwave gem</a> to allow photos to be uploaded. The ReadMe was pretty straight forward. It lead me to installing the fog gem which lead me to setting up an Amazon S3 server. Some of these docs weren’t as simple to navigate, but after some persistence I got through it and it worked. Only later did I realize that my carrierwave initializer broke my <a href="https://travis-ci.org/">Travis CI</a> because it didn’t allow for tests and was attempting to hit my Amazon server without its keys. After reading documentation and some help from a teacher, we were able to write up an if statement to satisfy carrierwave locally when the app is in test mode.</p><h4>Basic members vs Advanced members: Simple Tasting Notes vs Full Tasting Notes</h4><p>This is feature was very important to me because not everyone wants to fill out 20 fields about a wine they are tasting, others do. If a member is really into wine tasting, they should select to be an “advanced member” during registration or by editing their user information. If members don’t select anything, they will default to a basic member. The only difference between members is the tasting note form and show pages.</p><p>Please note that most fields provide options for the member to select from several options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*uv5mTMJlxGR_CpMOYPxiPw.png" /><figcaption><strong>Basic member new tasting note form</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*jZnnslG6Y2IQTv0a6IZjxA.png" /><figcaption><strong>Advanced member new tasting note form</strong></figcaption></figure><h4><em>Admin Only</em></h4><p>The admin in my app is very important because it acts as a filter to approve new wineries and make changes to existing ones (including delete). Admins right now can see tasting notes and user information. This might change if the app grows and members have privacy concerns.</p><h3>Deployment</h3><p>I started with a <a href="http://frozen-plains-8303.herokuapp.com/">Heroku generated url</a> since I host my app on <a href="https://heroku.com/">Heroku</a>, but having frozen-plains-8303.herokuapp.com as a url is kinda lame. So I purchased a domain name from <a href="https://www.namecheap.com/">Namecheap.com</a> and hooked it up.</p><h3>What’s next?</h3><p>I still have a few more things I’d like to get done on this app to make the user experience flow more smoothly from sorting on the index pages and seamlessly integrating adding a new wine from the tasting note form.</p><p>Creating this app definitely helped to refine and ingrain the skills that we learned in class. I’m thinking about the next projects and I’ll share once I’ve figured it out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2006ad18171" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gschool-chronicles/introducing-colorado-wine-tracker-a2006ad18171">Introducing… Colorado Wine Tracker!</a> was originally published in <a href="https://medium.com/gschool-chronicles">gSchool Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up AWS for Carrierwave]]></title>
            <link>https://medium.com/gschool-chronicles/setting-up-aws-for-carrierwave-17fa15377c19?source=rss----3790907c0b23---4</link>
            <guid isPermaLink="false">https://medium.com/p/17fa15377c19</guid>
            <dc:creator><![CDATA[Jadam]]></dc:creator>
            <pubDate>Mon, 22 Dec 2014 23:39:38 GMT</pubDate>
            <atom:updated>2015-01-26T11:02:28.400Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*Jvk5XBS6EAnGxAZRSCmJgg.jpeg" /></figure><p>Its only a handful of steps to get this up and running, but I found the docs were’t quite as explicit as I would have liked. In addition to having to add the fog gem you’ll also likely find you’ll want the dotenv gem aswell.</p><p>The fog gem can be dropped in your main group, but the dotenv-rails gem will need to be added with groups =&gt;[:development, :test] if you don’t already have that group.</p><pre>gem ‘fog’<br>gem ‘dotenv-rails’, :groups =&gt; [:development, :test]</pre><p>In your terminal run:</p><pre>$ bundle</pre><p>At the top level of your application’s tree create a .env and .env.example file.</p><p>In your .env file is where you’ll put your AWS keys. My file looks something like this:</p><pre>S3_KEY=s0m3_b1g_10ng_str!ng_0f_stuff<br>S3_SECRET=s0m3_b1g_10ng_str!ng_0f_stuff<br>S3_BUCKET=&quot;bucket_file_name&quot;</pre><p>You’ll be copying everything from your .env file into your .evn.example file, but without all the secret values you filled in. The file only has the keys/variables and look something like the example below:</p><pre>S3_KEY=<br>S3_SECRET=<br>S3_BUCKET=</pre><p>This .env.example file is for anyone else who may be working off your code and lets them know what keys they’ll need to provide to get things running on their environment.</p><p>Next inside config/initializers create a carrierwave.rb file in which you’ll add:</p><pre>CarrierWave.configure do |config|<br>  config.fog_credentials = {<br>    :provider =&gt; ‘AWS’,<br>    :aws_access_key_id =&gt; ENV[‘S3_KEY’],<br>    :aws_secret_access_key =&gt; ENV[‘S3_SECRET’],<br>  }<br>  config.fog_directory = ENV[‘S3_BUCKET’]<br>end</pre><p>I’ve left out a few of the optional fields that are listed in Carrierwave’s docs. Then inside your XXXX_uploader.rb file uncomment the “storage :fog” option. Short of committing your changes that’s about it. One last step you’ll need to take if you’re using Heroku is setting those keys.</p><p>when pushing to Heroku you’ll need to set your AWS secrets separately:</p><pre>$ heroku config:set S3_KEY=s0m3_b1g_10ng_str!ng_0f_stuff S3_SECRET=s0m3_b1g_10ng_str!ng_0f_stuff S3_BUCKET=yourbucketname</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17fa15377c19" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gschool-chronicles/setting-up-aws-for-carrierwave-17fa15377c19">Setting up AWS for Carrierwave</a> was originally published in <a href="https://medium.com/gschool-chronicles">gSchool Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding at the Speed of Smooth]]></title>
            <link>https://medium.com/gschool-chronicles/coding-at-the-speed-of-smooth-992594d8822f?source=rss----3790907c0b23---4</link>
            <guid isPermaLink="false">https://medium.com/p/992594d8822f</guid>
            <dc:creator><![CDATA[David Middleton]]></dc:creator>
            <pubDate>Sun, 16 Nov 2014 21:47:22 GMT</pubDate>
            <atom:updated>2014-11-16T21:47:22.213Z</atom:updated>
            <content:encoded><![CDATA[<p>I used to play online poker professionally (2009–2011) and it involved making multiple decisions in a limited amount of time. I was fast. My speed was a great strength in certain situations and a great weakness in others. By playing more hands faster I was making more money…theoretically.</p><p><a href="http://i.imgur.com/drpshTK.gif">http://i.imgur.com/drpshTK.gif</a></p><p>I would hit plateaus where I was only thinking about what came immediately after my decision instead of giving myself room to think more creatively and about the decisions to come. This had a direct impact on my results. Instead of giving my brain time to filter all of the important information and plan ahead I was rushing and it was killing my progress and my winrate. It was (and still is) hard for me to pump my mental brakes. Similar to these plateaus is what I experience this week doing a Ruby on Rails exercise.</p><p>We had an assignment where we had to make a rails CRUD app from scratch and I got hung up early on with a simple syntax error in my migration. Instead of naming my migration “Statuses” it was named “Status”. My brain reacts to pressure with speed because that’s how it has been conditioned. Trying to get it done quickly took far longer than it would have going slowly. Going fast at trying to fix a bug or adding a feature is like slamming on the gas in the snow. Your tires are gonna spin really fast and you aren’t going to get anywhere. It is only in the application of gentle pressure and a slow speed that progress is made.</p><p>Being able to think and react quickly has been great for my workflow but the main adjustment I need to make is to do everything slower and with a more methodical mentality. The easiest way to do this is by writing down the solutions I think are possible, crossing them off a list, and asking the right questions.</p><p>In coding one thing will always be true for me: “Slow is smooth and smooth is fast.”</p><p>Until next time!<br><a href="http://img.pandawhale.com/post-33537-Jim-Carrey-Truman-Show-gif-wha-cIrC.gif">http://img.pandawhale.com/post-33537-Jim-Carrey-Truman-Show-gif-wha-cIrC.gif</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=992594d8822f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gschool-chronicles/coding-at-the-speed-of-smooth-992594d8822f">Coding at the Speed of Smooth</a> was originally published in <a href="https://medium.com/gschool-chronicles">gSchool Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embracing the Sisterhood of Code]]></title>
            <link>https://medium.com/gschool-chronicles/embracing-the-sisterhood-of-code-9002a2971b1a?source=rss----3790907c0b23---4</link>
            <guid isPermaLink="false">https://medium.com/p/9002a2971b1a</guid>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <dc:creator><![CDATA[Beth Jaswa]]></dc:creator>
            <pubDate>Fri, 14 Nov 2014 00:05:44 GMT</pubDate>
            <atom:updated>2015-05-12T01:48:52.601Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>I was a bit hesitant to attend female-only meet ups. All I could imagine is something crazy from the Ya-Ya Sisterhood. But now I get it.</em></blockquote><p>When I left my last job, I had multiple people tell me I should check out groups like Women Who Code or Girl Develop It. I didn’t quite get it. Why would a female only meet up group be better than one that includes everyone in the industry? It’s not like there’s a Men Who Code or whatever group. I understand I am a minority in the tech field, but why draw attention to it? Since it’s a male dominated field, shouldn’t I just get used to it now?</p><p>I decided to go ahead and embrace the sisterhood of code and join the groups on Meet Up. One topic was particularly interesting and I decided to sign up for the wait list despite that it was in Denver (gSchool is in Boulder and traffic on 36 sucks y’all). I figured that perhaps I wouldn’t get into the event and I could continue to my avoidance plan. Welp I got into the event and since there was a wait list, I needed to decide if I was really going to attend. I didn’t want to prevent other women from attending if I wasn’t going to go. I decided to go and at least check it out. It wouldn’t hurt after all.</p><p>After a devouring some pizza, I narrowed in on some girls that seemed friendly and kinda like me. One was attending another code school and had a couple months left. One was in the insurance industry and didn’t have any coding experience. A couple others were at the end of their code school. We started chatting and had more in common than one might expect. We were bored in our current or old non-code job and felt like we had reached as far as we could or wanted to go. It was time for a change. Sweet- I have stuff in common with these girls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*BJlzdahvsJTLS8ao_9dnNg.jpeg" /></figure><p>The topic was “<strong>Landing Your Dream Job in Tech</strong>”. <a href="http://www.meetup.com/Women-Who-Code-Boulder-Denver/">Women Who Code </a>had a panel of five women with varying expertise. Most of the advice wasn’t female specific, but definitely helpful:</p><ul><li>Have an awesome portfolio that you’re proud of</li><li>Communicate what you are working on in your spare time, what drives you, what you want to learn</li><li>Get to know the company you are interviewing for. Maybe look beyond start up scene at schools, gov, ect</li><li>Look at the company website and evaluate what you like, what you don’t, and how you’d change it</li><li>Get involved &amp; be available — meet ups, github, twitter, and beyond</li><li>Ask about the workplace culture and environment</li></ul><p>But there was some differences which really made me appreciate being in a room full of women. A question was asked about how to adjust or get back into the industry after having a child. One panelist had recently rejoined the industry after being a stay-at-home mom for years. I appreciated hearing some their horror stories from interviews. Apparently some companies are afraid of how you as a woman will fit into their culture = red flag. I doubt these questions would have come up at a general panel session.</p><h3>A few take aways from the meet up:</h3><h4>Men’s vs Women’s Perception on Skills</h4><p>I know that I do a good job at things. I strive to do them correctly and in an efficient manner. I typically believe that most people have this mentality and this is the norm. I am not going above and beyond or anything special, but I’m learning that I’ve been wrong about this. Apparently I do more than the average person, but I don’t always realize it.</p><p>It was highlighted that men who have maybe 5 out of 10 necessary skills on a job description will apply for the job and feel really confident about it. A woman might have 8 out of 10 skills and think she doesn’t have enough skills and won’t apply. Perception and confidence frequently impact what jobs women get (or more importantly <em>don’t</em> get) because they don’t think they are worthy. Just knowing that I am prone to this perception, I can be aware of it and toss it to the curb. I was always the little sister that wanted to do whatever my older brother was doing. I can apply the same mentality to my career as well.</p><h4>“Be a learning animal”</h4><p>Always be learning something and continue to evolve. Enough said.</p><h4>“Don’t be a tech dinosaur”</h4><p>Opposite of being a learning animal… don’t get behind because it’ll be harder to catch up aka you are pretty screwed.</p><h3>The sisterhood of code is worthwhile</h3><p>For some reason, the sisterhood just seems more inviting. I think I’ll use female meet ups as a place to build my confidence and confide in other women possibly going through the same thing as me. It’s almost like Girl Scouts. Yeah I can hang with the boys, but every now and then it’s great to relate to some females. I’ll see you ladies soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9002a2971b1a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gschool-chronicles/embracing-the-sisterhood-of-code-9002a2971b1a">Embracing the Sisterhood of Code</a> was originally published in <a href="https://medium.com/gschool-chronicles">gSchool Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pull Request in One Minute]]></title>
            <link>https://medium.com/gschool-chronicles/pull-request-in-one-minute-a714581cacd1?source=rss----3790907c0b23---4</link>
            <guid isPermaLink="false">https://medium.com/p/a714581cacd1</guid>
            <dc:creator><![CDATA[Jadam]]></dc:creator>
            <pubDate>Mon, 10 Nov 2014 23:40:39 GMT</pubDate>
            <atom:updated>2014-11-10T23:40:39.145Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4uNrWchlMiNjDJNFn3BYZA.jpeg" /></figure><p>First off you should be doing all your work in a new branch. Once you’re code is ready for production run your typical Git status, add and commit commands. Your push will need to include the branch name. Something like the following:</p><pre>$ git push desc-exercises </pre><p>After you’ve pushed head over to Github and jump into the repo you’re making a pull request to. Near the top you should see the name of the branch you just pushed highlighted in yellow. On the right there will be a green button that says ‘Compate &amp; pull request’. Click that button and you will be taken to a view page of your push with yet another green button to click, ‘Create pull request’. Once you’ve hit that one your request is submitted for review by the overlords.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a714581cacd1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gschool-chronicles/pull-request-in-one-minute-a714581cacd1">Pull Request in One Minute</a> was originally published in <a href="https://medium.com/gschool-chronicles">gSchool Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Atom: My New Friend]]></title>
            <link>https://medium.com/gschool-chronicles/atom-my-new-friend-98fae3742e1b?source=rss----3790907c0b23---4</link>
            <guid isPermaLink="false">https://medium.com/p/98fae3742e1b</guid>
            <dc:creator><![CDATA[Laura Hasemeyer]]></dc:creator>
            <pubDate>Thu, 06 Nov 2014 18:10:47 GMT</pubDate>
            <atom:updated>2014-11-06T00:29:07.696Z</atom:updated>
            <content:encoded><![CDATA[<p>Atom is my new friend. I may be only three weeks into gSchool, but I have spent hours upon hours staring at code in Atom. And like any new friend, I have decided to make the effort to get to know it on a deeper level.</p><p>Here is a short site detailing the reasons why Atom is awesome, and also a link to download it: <a href="https://atom.io/">https://atom.io/</a></p><p>Here are the basic hot keys I am memorizing first for the Atom editor:</p><p><strong>command + d — — </strong>select current word<br><strong>command + l — — </strong>select current line<br><strong>shift + arrow(↑↓) — — </strong>highlight up or down a line<br><strong>option + shift + arrow(←→) —— </strong>highlight to the right or left<br><strong>command + shift + arrow(←→↑↓) — — </strong>highlight to far left, right, top, or botom<br><strong>command + ][ — — </strong>indent or outdent current line (or group of lines)<br><strong>control + command + arrow(↑↓) — — </strong>move current line up or down<br><strong>control + shift + k — — </strong>delete current line<br><strong>option + delete </strong>OR <strong>option + backspace — — </strong>delete to beginning OR end of word<br><strong>command + enter </strong>OR <strong>command + shift + enter — — </strong>insert new line below or above<br><strong>shift + command + d — — </strong>duplicate current line<br><strong>command + j — — </strong>join current and next lines<br><strong>command + arrow(←→) — — </strong>jump to the far left, right, top, or botom<br><strong>option + arrow(←→) — — </strong>skips one word to the left or right</p><p>If you are ready for more commands, here is an excellent Atom cheat sheet: <a href="http://d2wy8f7a9ursnm.cloudfront.net/atom-editor-cheat-sheet.pdf">http://d2wy8f7a9ursnm.cloudfront.net/atom-editor-cheat-sheet.pdf</a></p><p>You can also find an even more comprehensive sheet in Atom by hitting ‘ <strong>command + , ‘ </strong>and clicking on “Keybindings” on the left side.</p><p>And if you’re feeling the urge to personalize your Atom, here’s how:</p><ul><li>Go to <a href="https://atom.io/themes">https://atom.io/themes</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*21niavsaXNbLnlusJ1ppCQ.png" /></figure><ul><li>“Syntax” concerns the appearance of the main typing area</li><li>“UI” is ‘user interface’ – the buttons, side bar, tabs, etc.</li><li>Copy the name of the UI or Syntax that you like</li><li>Open preferences in Atom (<strong>command </strong>+ <strong>,).</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mxr3Swsv_zOgzuh0PGn-Dw.png" /></figure><ul><li>Click on “Themes”. In the “Install Themes” section, paste the UI or Syntax you chose, then hit enter.</li><li>Find your selection, click “Install”</li><li>In the “Choose a Theme” section of the same page, select your choice in the UI or Syntax drop-down list.</li><li>Your Atom should change immediately.</li></ul><p>I expect Atom and I to have an intense relationship consisting of high frustration countered by extreme joy. I also expect these cheats to help the coding process go a little more smoothly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98fae3742e1b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gschool-chronicles/atom-my-new-friend-98fae3742e1b">Atom: My New Friend</a> was originally published in <a href="https://medium.com/gschool-chronicles">gSchool Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[This is how you do basic CRUD:]]></title>
            <link>https://medium.com/gschool-chronicles/this-is-how-you-do-basic-crud-5777b9445ac5?source=rss----3790907c0b23---4</link>
            <guid isPermaLink="false">https://medium.com/p/5777b9445ac5</guid>
            <dc:creator><![CDATA[Jadam]]></dc:creator>
            <pubDate>Thu, 06 Nov 2014 16:17:15 GMT</pubDate>
            <atom:updated>2015-01-14T16:48:58.850Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aaf9jntAnLqZsEsfS7XCBQ.png" /></figure><h2>This is how you CRUD</h2><p>This run through is structured in a way that wont stop to explain all the small things about syntax or purpose or files and methods. Rather we will be going through a process of <em>error driven development </em>to guide us along our crudding journey. CRUD, or Create Read Update Destroy, is a core element of building in Ruby on Rails and many other languages. There are plenty of resources out there that provide a much more in depth explanation of what CRUD is, but we’re going to jump right into knocking out some CRUD here.</p><p>Open up your terminal to start out, and punch the following lines of code in, one row at a time.</p><pre>$ rails new widgets -—database=postgresql<br>$ cd widgets<br>$ bundle<br>$ rake db:create</pre><p>In a second terminal tab run your rails server</p><pre>$ rails s</pre><p>Now head over to your browser and enter <em>localhost:3000 </em>into your address bar. You should see the <a href="http://guides.rubyonrails.org/images/getting_started/rails_welcome.png">Rails Welcome Page</a>.</p><p>Back in terminal we’ll generate a database table for some widgets to CRUD and then open up our <a href="https://atom.io/">Atom editor</a> to check out the file.</p><pre>$ rails g migration MyWidgetsAndThings<br> invoke active_record<br> create db/migrate/20141106150725_my_widgets_and_things.rb<br>$ atom .</pre><p>Now in the text editor we’ll create a new database table by putting in the following code within the existing <em>def change </em>and <em>end </em>block.<br><strong>db/migrate/20141106150725_my_widgets_and_things.rb</strong></p><pre>create_table :widgets do |t|<br> t.string :name<br> t.string :description<br> t.integer :age<br>end</pre><p>Additional datatypes to choose from: <a href="http://stackoverflow.com/questions/17918117/rails-4-datatypes">http://stackoverflow.com/questions/17918117/rails-4-datatypes</a></p><p>Once our widgets database table is created we’ll head back over to the terminal and <em>migrate </em>those changes.</p><pre>$ rake db:migrate</pre><pre>== 20141106025705 MyWidgetsAndThings: migrating ==================<br> —  create_table(:widgets)<br> -&gt; 0.0052s<br>== 20141106025705 MyWidgetsAndThings: migrated (0.0053s) =========</pre><blockquote><em>Your terminal output should look something like the one above</em></blockquote><p>That should be the last time we’ll need the terminal for a while. Back over in Atom, open up your <em>routes.rb </em>file. We will be adding in two lines here: <em>resources :widgets </em>and <em>root ‘widgets#index’</em><br><strong>config/routes.rb</strong></p><pre>Rails.application.routes.draw do<br> resources :widgets<br> root ‘widgets#index’<br>end</pre><blockquote><em>You can delete all the commented out text (the light grey text with hashtags in front of it) If you choose to do that your file should have 4 lines like the code above.</em></blockquote><p>Next create a file inside of your <em>apps/controllers </em>directory, name it<br><em>widgets_controller.rb </em>and drop in the following code to set your index action.<br><strong>app/controllers/widgets_controller.rb</strong></p><pre>class WidgetsController &lt; ApplicationController<br> def index<br> end<br>end</pre><blockquote><em>Check localhost:3000 ~&gt; We have our first desired error: ‘The action ‘index’ could not be found for PlantsController’</em></blockquote><p>So lets add an index action. Create a folder named <em>widgets </em>within the <em>app/views </em>directory. Then create a file named <em>index.html.erb </em>and add in the following code:<br><strong>app/views</strong></p><pre>&lt;h1&gt;Widgets&lt;/h1&gt;<br> &lt;%= link_to ‘New Widget’, new_widget_path %&gt;</pre><blockquote>Check localhost:3000 ~&gt; Click on the ‘New Widget’ link. You should be rewarded with a fail message stating: ‘action new could not be found’</blockquote><p>To resolve that disconnect provide your controller with that new action:<br><strong>app/controllers/widgets_controller.rb</strong></p><pre>def new<br>end</pre><blockquote>Check localhost:3000/widgets/new ~&gt; Our first ‘Missing template’ error.</blockquote><p>Create a view file named <em>new.html.erb </em>inside of your <em>app/views/widgets </em>directory and enter in the following code:<br><strong>app/views/widgets</strong></p><pre>&lt;h1&gt;Widget Factory&lt;/h1&gt;<br>&lt;%= form_for <a href="http://twitter.com/widget">@widget</a> do |f| %&gt;<br> &lt;%= f.label :name %&gt;<br> &lt;%= f.text_field :name %&gt;</pre><pre>&lt;%= f.label :description %&gt;<br> &lt;%= f.text_field :description %&gt;</pre><pre>&lt;%= f.label :age %&gt;<br> &lt;%= f.text_field :age %&gt;</pre><pre>&lt;%= f.submit %&gt;<br>&lt;% end %&gt;</pre><blockquote>Check localhost:3000/widgets/new ~&gt; Here we get a ‘<em>First argument in form cannot contain nil or be empty’ error as expected.</em></blockquote><p>Backover in our <em>new </em>action within the controller we’ll add the following line of code: <a href="http://twitter.com/widget"><em>@widget</em></a><em> = Widget.new</em></p><p><strong>app/controllers/widgets_controller.rb</strong></p><pre>def new<br> <a href="http://twitter.com/widget">@widget</a> = Widget.new<br>end</pre><blockquote>Check localhost:3000/widgets/new ~&gt; You should get ‘<em>uninitialized constant PlantsController::Plant’ </em>If you happen to get the following error <em>‘</em>undefined method `new’ for Widget:Module’ tweet at me to resolve it.</blockquote><p>This means we need a Model. To create one well need to add a file named <em>widget.rb (</em>singular widget) inside the <em>app/models </em>directory with the code:<br><strong>app/models</strong></p><pre>class Widget &lt; ActiveRecord::Base</pre><pre>end</pre><blockquote>Check localhost:3000<em>/widgets/new ~&gt; We should now have our new page with fields and a button. Click that button and you should get ‘The action ‘create’ could not be found for WidgetsController</em></blockquote><p>We need a <em>create </em>action. Drop the following code into your controller under you new action:<br><strong>app/controllers/widgets_controller.rb</strong></p><pre>def create<br>end</pre><blockquote>Check localhost:3000/widgets/new ~&gt; Click that button again and you will see a ‘<em>missing template</em>’ error.</blockquote><p>Unlike new, create does not need a view. Instead we will just redirect users back to the index page after they create a new widget with <em>redirect_to root_path </em>in our create action.<br><strong>app/controllers/widgets_controller.r</strong></p><pre>def create<br> redirect_to root_path<br>end</pre><blockquote><em>Create a widget<br></em>Check localhost:3000/widgets/new ~&gt; Clicking the button again you will be sent to your index page.</blockquote><p>That’s great, but it doesn’t actually save the data you filled in the fields. To accomplish that drop the following code inside your create action, <strong>above </strong>the redirect you just added.<br><strong>/controllers/widgets_controller.rb</strong></p><pre>def create<br> <a href="http://twitter.com/widget">@widget</a> = Widget.new(params.require(:widget)<br> .permit(:name, :destroy, :age))<br> <a href="http://twitter.com/widget">@widget</a>.save<br> redirect_to root_path<br>end</pre><blockquote>Check localhost:3000/widgets/new <em>~&gt; Fill in the fields and click the button. Nothing will show, but it is saving now.</em></blockquote><p>The first step in getting it to show we will be to add a table into our <em>index.html.erb </em>file.<br><strong>views/widgets/index.html.erb</strong></p><pre>&lt;% <a href="http://twitter.com/widgets">@widgets</a>.each do |widget| %&gt;<br> &lt;table&gt;<br> &lt;tr&gt;<br> &lt;th&gt;Name&lt;/th&gt;<br> &lt;th&gt;Description&lt;/th&gt;<br> &lt;th&gt;Age&lt;/th&gt;<br> &lt;/tr&gt;<br> &lt;tr&gt;<br> &lt;td&gt;&lt;%= widget.name %&gt;&lt;/td&gt;<br> &lt;td&gt;&lt;%= widget.description %&gt;&lt;/td&gt;<br> &lt;td&gt;&lt;%= widget.age %&gt;&lt;/td&gt;<br> &lt;td&gt;&lt;%= link_to ‘Edit’, ‘#’ %&gt;&lt;/td&gt;<br> &lt;td&gt;&lt;%= link_to ‘Show’, ‘#’ %&gt;&lt;/td&gt;<br> &lt;td&gt;&lt;%= link_to ‘Delete’, ‘#’ %&gt;&lt;/td&gt;<br> &lt;/tr&gt;<br> &lt;/table&gt;<br>&lt;% end %&gt;</pre><blockquote>Check localhost:3000 <em>~&gt; There’s a place for it to show now but we’re getting a ‘undefined method `each’ for nil:NilClass’ error.</em></blockquote><p><strong>/controllers/widgets_controller.rb<br></strong>Drop the following code inside your new action:<br>`<a href="http://twitter.com/widgets">@widgets</a> = Widget.all`</p><blockquote>Check localhost:3000 <em>~&gt; Widgets appear!</em></blockquote><p><strong>/views/widgets/index.html.erb<br></strong>Next we’ll replace the hashtag and quotes for the ‘Edit’ `link_to`line of code with `edit_widget_path(widget)` so that it looks like the following:</p><pre>…<br> &lt;td&gt;&lt;%= plant.age %&gt;&lt;/td&gt;<br> &lt;td&gt;&lt;%= link_to ‘Edit’, <strong>edit_widget_path(widget) </strong>%&gt;&lt;/td&gt;<br> &lt;td&gt;&lt;%= link_to ‘Show’, ‘#’ %&gt;&lt;/td&gt;<br>…</pre><blockquote>Check localhost:3000 <em>~&gt; If you click our updated “edit” link you will get: “The action ‘edit’ could not be found for WidgetsController”</em></blockquote><p>Under your create action add an edit action the same way you did for index, new, and create.<br><strong>/controllers/widgets_controller.rb</strong></p><pre>def edit<br>end</pre><blockquote>Check localhost again <em>~&gt; Do a hard refresh on the page and get: ‘Missing template widgets/edit’</em></blockquote><p>Create a new view called <em>edit.html.erb </em>inside your <em>/views/widgets </em>directory and add the following code:<br><strong>/views/widgets</strong></p><pre>&lt;h1&gt;Edit Widget&lt;/h1&gt;<br>&lt;%= form_for <a href="http://twitter.com/widget">@widget</a> do |f| %&gt;<br> &lt;%= f.label :name %&gt;<br> &lt;%= f.text_field :name %&gt;</pre><pre>&lt;%= f.label :description %&gt;<br> &lt;%= f.text_field :description %&gt;</pre><pre>&lt;%= f.label :age %&gt;<br> &lt;%= f.text_field :age %&gt;</pre><pre>&lt;%= f.submit %&gt;<br>&lt;% end %&gt;</pre><blockquote>Check localhost:3000/widgets/1/edit <em>~&gt; </em>And get this message: <em>‘First argument in form cannot contain nil or be empty’</em></blockquote><p>Back in your controller add <a href="http://twitter.com/widget"><em>@widget</em></a><em> = Widget.find(params[:id]) </em>inside your new edit action, so that it looks like this:<strong><br>/controllers/widgets_controller.rb</strong></p><pre>def edit<br> <a href="http://twitter.com/widget">@widget</a> = Widget.find(params[:id])<br>end</pre><blockquote>Check localhost:3000<em>/widgets/1/edit ~&gt; Click ‘Update Widget’ button and get this error: ‘The action ‘update’ could not be found for WidgetsController’</em></blockquote><p>Under your edit action add an update action.<br><strong>/controllers/widgets_controller.rb</strong></p><pre>def update<br>end</pre><blockquote>Check localhost:3000/widgets/1/edit <em>~&gt; ‘Missing template widgets/update’</em></blockquote><p>Update doesn’t get a view. We just want to make sure all the data is updated for our widget. `if` that happens we will just redirect the user to the index. `Else` should that not happen we’ll render the edit page again:<br><strong>/controllers/widgets_controller.rb</strong></p><pre>def edit<br>  <a href="http://twitter.com/widget"><strong>@widget</strong></a><strong> = Widget.find(params[:id])<br> if </strong><a href="http://twitter.com/widget"><strong>@widget</strong></a><strong>.update(params.require(:widget)<br> .permit(:name, :description, :age)<br> redirect_to root_path<br> else<br> render :edit<br> end</strong><br>end</pre><blockquote>Check localhost:3000/widgets/1/edit <em>~&gt; We should see that the changes we made work when you click the update button.</em></blockquote><p>Next up the show link. Let’s fix that it currently doesn’t go anywhere by replacing the `’#’` with the path `widget_path(widget)`<br><strong>/views/widgets/index.html.erb</strong></p><pre>…<br> &lt;td&gt;&lt;%= link_to ‘Edit’, edit_widget_path(widget) %&gt;&lt;/td&gt;<br> &lt;td&gt;&lt;%= link_to ‘Show’, <strong>widget_path(widget) </strong>%&gt;&lt;/td&gt;<br> &lt;td&gt;&lt;%= link_to ‘Delete’, ‘#’ %&gt;&lt;/td&gt;<br>…</pre><blockquote>Check localhost:3000 <em>~&gt; The action ‘show’ could not be found for WidgetsController is what we’ll get when we click the show link.</em></blockquote><p>Under your update action add a show action.<br><strong>/controllers/widgets_controller.rb</strong></p><pre>def show<br>end</pre><blockquote>Check localhost:3000/widgets/1 <em>~&gt; ‘Missing template widgets/show’</em></blockquote><p>Create a new view called <em>show.html.erb </em>and insert the following code:<br><strong>/views/widgets</strong></p><pre>&lt;h1&gt;&lt;%= <a href="http://twitter.com/widget">@widget</a>.name %&gt;&lt;/h1&gt;<br>&lt;%= <a href="http://twitter.com/widget">@widget</a>.description %&gt;&lt;/br&gt;<br>&lt;%= <a href="http://twitter.com/widget">@widget</a>.age %&gt;&lt;/br&gt;<br>&lt;%= link_to ‘All Widgets’, widgets_path %&gt; |<br>&lt;%= link_to ‘Edit’, edit_widget_path(<a href="http://twitter.com/widget">@widget</a>) %&gt;</pre><blockquote><em>Check 3000/widgets/1 ~&gt; We get a ‘NoMethodError’: ‘undefined method `name’ for nil:NilClass’ because we haven’t set our widgets instance variable in the show action yet.</em></blockquote><p>Add: <a href="http://twitter.com/widget"><em>@widget</em></a><em> = Widget.find(params[:id]) </em>Inside your show action.<br><strong>/controllers/widgets_controller.rb</strong></p><pre>def show<br> <a href="http://twitter.com/widget">@widget</a> = Widget.find(params[:id])<br>end</pre><blockquote>Check localhost:3000/widgets/1 <em>~&gt; You’ll see your widget’s name in bold and its description and age. Click the ‘All Widgets’ link to get back to the index page.</em></blockquote><p><strong>/views/widgets/index.html.erb<br></strong>Swap <em>project_path(project) </em>for the final <em>’#’ </em>in the delete link. We’ll also add in a comma and additional functionality that the destroy action requires in the form of: <em>, method: :delete</em></p><p>The full line should now look something like this:</p><pre>…<br> &lt;td&gt;&lt;%= link_to ‘Show’, plant_path(plant) %&gt;&lt;/td&gt;<br> &lt;td&gt;&lt;%= link_to ‘Delete’, <strong>project_path(project), method: :delete </strong>%&gt;&lt;/td&gt;<br> &lt;/tr&gt;<br>…</pre><blockquote>Check localhost:3000 <em>~&gt; Click on your ‘Delete’ link and you should get a familiar ‘Unknown action’ fail screen.</em></blockquote><p>To remedy that we will add a destroy action.<br><strong>/controllers/widgets_controller.rb</strong></p><pre>def destroy<br>end</pre><blockquote>Check localhost:3000 <em>~&gt; Now the expected ‘Template is missing’ fail screen.</em></blockquote><p>Just like our create and update actions, the destroy action will not require a<br>view. Instead we will verify the widget, destroy the widget, and then redirect the user to the index page within the action with the following code:<br><strong>/controllers/widgets_controller.rb</strong></p><pre>def destroy<br> <a href="http://twitter.com/widget">@widget</a> = Widget.find(params[:id])<br> <a href="http://twitter.com/widget">@widget</a>.destroy<br> redirect_to widgets_path<br>end</pre><blockquote>Check localhost:3000 <em>~&gt; Click the ‘Delete’ link and it should disappear.</em></blockquote><p>Congratulations! You’re the proud owner of a very ugly and useless web app. Feel free to mess around with the code, break it, add some bootstrap, add another round of crud, whatever you want.</p><p>I hope this was a helpful tutorial for CRUD. Consider going back though and googling any terms, concepts, or syntax you want to have a deeper understanding of. Once you can get through this process with minimal referencing you will be on your way to develpoing Ruby on Rails apps.</p><p><em>A markdown version of this CRUD run-through is available on my github: </em><a href="https://github.com/MrJadaml/widgets"><em>https://github.com/MrJadaml/widgets</em></a><em> .</em></p><p><em>If you have any question feel free to comment in the side bar or tweet at me: </em><a href="http://www.twitter.com/mrjadaml"><em>@Mrjadaml</em></a></p><p>…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5777b9445ac5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gschool-chronicles/this-is-how-you-do-basic-crud-5777b9445ac5">This is how you do basic CRUD:</a> was originally published in <a href="https://medium.com/gschool-chronicles">gSchool Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>