<?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 Meghan Stang on Medium]]></title>
        <description><![CDATA[Stories by Meghan Stang on Medium]]></description>
        <link>https://medium.com/@mstang15?source=rss-987e109b632b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uLwlg4c8cNjwV0eGtrmymg.jpeg</url>
            <title>Stories by Meghan Stang on Medium</title>
            <link>https://medium.com/@mstang15?source=rss-987e109b632b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 13:59:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mstang15/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[Rales Engine (but mostly Haikus)]]></title>
            <link>https://medium.com/@mstang15/rales-engine-but-mostly-haikus-7c5bb616be39?source=rss-987e109b632b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c5bb616be39</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Meghan Stang]]></dc:creator>
            <pubDate>Mon, 03 Dec 2018 07:05:16 GMT</pubDate>
            <atom:updated>2018-12-03T07:05:16.278Z</atom:updated>
            <content:encoded><![CDATA[<p>A series of Haikus and reflections regarding my first project in Mod 3 at Turing, School of Software and Design.</p><blockquote>Is it Rales or Rails</blockquote><blockquote>I’m honestly not too sure</blockquote><blockquote>A typo perhaps?</blockquote><p>I’m going to go with ‘Rales’ because I like to think that Rales Engine is a play on Sales Engine.</p><p>The goal of this project was to learn how to build single-responsibility controllers and how to develop a versioned API. A flashback to Mod 1, we are back using Ruby (this makes me so happy), but we are also working with our object relational mapper, ActiveRecord. We’ve had the chance to work with ActiveRecord previously, but with this project, we needed to work with advanced calls to perform complicated business intelligence.</p><h3>Planning and Approach</h3><blockquote>Planning and Approach</blockquote><blockquote>Planning and Approach, oh yeah!</blockquote><blockquote>Planning and Approach</blockquote><p>I have used these Sales Engine CSV files previously in a project in Mod 1, so I was lucky enough to be familiar with the attributes and relationship between all of my models (invoices, items, invoice_items, merchants, customers, transactions).</p><p>After this project was introduced, I tried to hit the ground running. I quickly developed my rails app, required the necessary gems, and started writing my import task.</p><p>Within my first two days of the project, I had all of my routes and controllers set up for everything but the Business Intelligence.</p><h3>Challenges</h3><blockquote>def ActiveRecord</blockquote><blockquote>‘def’ as in ‘definitely’</blockquote><blockquote>Not a method name</blockquote><p>As I mentioned earlier, I’ve used ActiveRecord before, however these more advanced Business Intelligence query’s were new to me. Within ActiveRecord, I’ve noticed that I struggle mainly when it comes to deciding how to sum a column, what to group by, or how to order.</p><p>Relying mainly on the spec harness to check my work (I’ll explain this in the hindsight portion below), I did run into a few frustrations with my rake getting aborted and not being able to adequately test all of my routes. I wish I could have solved all of these issues from the harness, but unfortunately, I was not able to.</p><p>Early this week, one of our instructors taught a great lesson on dissecting and breaking down ActiveRecord calls. As a class, we came up with a visual for what it would look like to create a query for most items sold. After our lesson, our cohort broke up six of the Business Intelligence problems, diagramed them, and posted them around the room. This was very helpful for me when working through ActiveRecord on this project.</p><h3>Fun Moments</h3><blockquote>Brainstorm with cohort</blockquote><blockquote>Repetition everywhere!</blockquote><blockquote>muscle memory</blockquote><p>I’m enjoying Mod 3! Mod 1 has been my favorite so far — I loved the logic of it! Mod 2 was difficult for me. It took me longer than I was expecting to finally get a grasp on MVC principals and routes, but I get it now! Being in Mod 3, though still difficult, is a breath of fresh air because I feel like I’m having fun again! I’m back in the logic, and that excites me.</p><p>One thing I really enjoyed about this project was how repetitious it was. This really helped me to develop some muscle memory — something I couldn’t say I developed in Mod 2 since everything was always so different. I really appreciated this project for that reason.</p><h3>Hindsight</h3><blockquote>It’s 20/20</blockquote><blockquote>Test Driven Development</blockquote><blockquote>Forgot about that</blockquote><p>I was eager to start this project, and immediately jumped in to create my models, my serializers, my namespaced routes, and so on. I could see my progress through running the server, and I was getting the results I was hoping for. This immediate gratification led me down a very dark dark road which led to...well… no tests. I know the importance of tests, I’ve relied on them for my whole first half of Turing. However, I got on a roll (or so I thought), and before I knew it, it was Sunday night, I was relying on the spec harness to identify my errors, and I had run out of time to finish writing my own tests. In the future, I will definitely make more of an effort to write my tests before developing my code.</p><p>I also had several issues connecting my ActiveRecord calls because I didn’t set up the correct relationships in the beginning. Well, they were all correct, but I just needed more. I had forgotten about a lot of through relationships. Nearly 3/4 of the way through the project, I took the time to diagram my schema. I imagine this would have alleviated a great deal of frustration had I drawn out the schema ahead of time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QNihZUFtUl6QRH-MA3HQQQ.png" /><figcaption>Rales Engine Schema</figcaption></figure><h3>Takeaways</h3><blockquote>APIs are cool</blockquote><blockquote>Excited to consume them</blockquote><blockquote>That’ll be cool too</blockquote><p>As mentioned earlier, I really would like to focus on testing on our upcoming projects. I think that in the long run, not testing my code made it much more difficult for me to complete the project.</p><p>I am also grateful that I have learned how to create an API before learning to consume them. I believe that this process of creating one will help me better understand how to take an API and implement it into my own code.</p><p>Overall, I feel comfortable with what I have accomplished on this project. I know that I have a lot I can still learn about creating API’s, but I feel that with more time and practice, I’ll be able to create API’s with much more confidence and ease.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c5bb616be39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Name::Space]]></title>
            <link>https://medium.com/@mstang15/name-space-cbf198e6f3ec?source=rss-987e109b632b------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbf198e6f3ec</guid>
            <category><![CDATA[namespaces]]></category>
            <category><![CDATA[namespacing]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[turing]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Meghan Stang]]></dc:creator>
            <pubDate>Mon, 05 Nov 2018 19:46:43 GMT</pubDate>
            <atom:updated>2018-11-07T05:07:43.997Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been a student at <a href="https://www.turing.io/?gclid=Cj0KCQiA8f_eBRDcARIsAEKwRGcl9SzcsCYts8d_bpYlvJ-bkKFQX3iLCL-VWps0U2Y-XNXLXeeSF2kaAr2ZEALw_wcB">Turing School of Software and Design</a> in Denver, Colorado for nearly three months now. I am currently in the last week of our second inning(out of four). This last week consists of technical assessments, verbal assessments, and due dates for blog posts and final individual projects. As I write this, I am sitting in a room, waiting to be called in to do my technical assessment.</p><p>It has been communicated via instructors, that a fluent knowledge of namespacing is required in order to perform well on today’s assessment. So why not kill two birds with one stone and review namespacing while also completing my blog post assignment!? <a href="https://media1.giphy.com/media/9W54HrZPHv9fy/giphy.gif?cid=3640f6095be0a1b347354d6c6b7be711">Efficient</a>.</p><p>Namespacing allows us to :</p><ul><li>nest a controller for a resource into a directory of another controller</li><li>change the routes that a user would be visiting</li><li>change path helpers</li><li>help make readable, specific, and organized routes</li></ul><p>Namespacing is useful when we want a certain controller to have a different type of view, or access, than the original controller would have allowed for. For example, let’s say you were creating a platform for an e-commerce app. Within this app, there are different types of users. You’ll have visitors, you’ll have registered customers, you’ll have merchants, and you’ll also have admin… that’s a lot of users to control! Registered users, and merchants have identical viewing capabilities when it comes to their user_controller. They both have a user_id, they both can log in and log out, and they both can edit only their information. An admin on the other hand, has all of the abilities as a registered user and merchant, but more. They have the capability to see all of the users and merchants, and edit any of their information. Therefore, the CRUD functionalities for the user_controller(s) between Admin users, and Registered/Merchant users are fairly different.</p><h3><strong>How To Create A Namespace</strong></h3><p><strong>Namespacing Step 1</strong>: Define your route</p><p>Within your ‘/config/routes.rb’ define your route.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vsLojg-wEh6fB4Ybt8rWAA.png" /></figure><p>When defining these routes, I am thinking about what I want my <a href="https://searchmicroservices.techtarget.com/definition/URI-Uniform-Resource-Identifier">URI</a> to look like. Since my admins have special privileges within the user_controller, I want my path to look something like ‘/admin/users/’. Line 3 in the code above gives me the ‘/admin/’ part of the URI. Earlier, I mentioned that the special privileges the admin user will have are going to be within the index, edit, and the update CRUD. Because I only am using three out of the five CRUD functions, I’m going to limit my users resource on line 4 to just apply to the index, edit, and update functions.</p><p>If we were to run ‘rake routes’ in our terminal, we will see the namespaced routes we just created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RMK1iOJivff6wGkMdN5v1A.png" /></figure><p><strong>Namespacing Step 2</strong>: Nest your controllers</p><p>If you look at the Controller#Action column in the last picture in Step 1, you’ll notice that the controller is noted by ‘admin/users’. The ‘admin’ portion of this controller was created when we wrote line 3 in our ‘/config/routes’ file. This should tell us that in order to get to any of the actions that our routes are calling, we must first go to an admin folder, and then to the user controller within that folder. Therefore, we should create the following directory and file so that your tree looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*7KSh5uasQKXERLSJJau4mg.png" /></figure><p><strong>Namespacing Step 3</strong>: Define your new users_controller class</p><p>Within the users_controller that we just created, we define the class by using the scope resolution operator (::) because we need to tell the rails application that we have namespaced this controller. You’ll also notice that the I am inheriting from “UsersController” (in green). The reason I chose to inherit from UsersController is because I still wanted my admin to have the same capabilities as my registered users. By inheriting from UsersController, I also inherit the actions that I haven’t overridden through the admin users controller. Normal protocol is to just inherit from ApplicationController. Since my UserController already inherits from ApplicationController, I already have access to that as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6fqsI2CTBRo9zrAscRzjGQ.png" /></figure><p><strong>Namespacing Step 4</strong>: Nest your views</p><p>Since our users_controller holds our index method which outputs information onto a page, we are going to need a new index.html file for our users_controller that is nested within our admin directory. Therefore, let’s create a directory and view file such that your tree looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*zq2LIHDXYfC6-4XpwZX_-g.png" /></figure><h3><strong>That’s all it is! Easy… right?</strong></h3><p>Make sure that throughout your application, that you are referencing your rake routes for the correct path helpers to call. Since in my example, my new controller inherited from my registered users user_controller, I know I’m going to have other routes that will look similar to each other. After adding my basic users routes in, my rake routes might look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KVF4eouoZsGhphNLKsUrIQ.png" /></figure><p>It’s important that you reference these rake routes and use the correct prefix when calling your path helpers within your application.</p><p>Whether this was your first time hearing of Namespacing, or just a review for you, I hope this information was helpful. Good luck on your endeavors… I’m off to take a test.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbf198e6f3ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>