<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mpuchyr</title>
    <description>The latest articles on DEV Community by mpuchyr (@mpuchyr).</description>
    <link>https://dev.to/mpuchyr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F937697%2F79e6aaba-b3af-449e-803d-66dc67c870e6.jpeg</url>
      <title>DEV Community: mpuchyr</title>
      <link>https://dev.to/mpuchyr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mpuchyr"/>
    <language>en</language>
    <item>
      <title>Rails - Getting the Current URI</title>
      <dc:creator>mpuchyr</dc:creator>
      <pubDate>Tue, 01 Nov 2022 18:23:49 +0000</pubDate>
      <link>https://dev.to/mpuchyr/rails-getting-the-current-uri-1fmo</link>
      <guid>https://dev.to/mpuchyr/rails-getting-the-current-uri-1fmo</guid>
      <description>&lt;p&gt;As I was attempting to figure out a way to conditionally render a page that required information from the uri, one idea that I had required a way to retrieve the entire url.&lt;/p&gt;

&lt;p&gt;After doing some searching, I found the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;current_uri = request.env['PATH_INFO']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This acquires the entire current path in the address bar.&lt;/p&gt;

&lt;p&gt;While I did not end up using the solution using the path and instead used params, I felt that this might be good information to have should I ever require the full path.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Order of Routes in Rails</title>
      <dc:creator>mpuchyr</dc:creator>
      <pubDate>Thu, 13 Oct 2022 17:02:03 +0000</pubDate>
      <link>https://dev.to/mpuchyr/order-of-routes-in-rails-h5g</link>
      <guid>https://dev.to/mpuchyr/order-of-routes-in-rails-h5g</guid>
      <description>&lt;p&gt;While adding features to a class project, I was struggling with an error that took me some time to debug. This post is meant as a reminder to myself (and possibly others) that ROUTE ORDER IN RAILS MATTERS.&lt;/p&gt;

&lt;p&gt;Originally, I had the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  get("/movies", { :controller =&amp;gt; "movies", :action =&amp;gt; "index"})
  get("/movies/:id", { :controller =&amp;gt; "movies", :action =&amp;gt; "movie"})
  get("/delete_movie/:id", { :controller =&amp;gt; "movies", :action =&amp;gt; "delete"})
  get("/movies/new", {:controller =&amp;gt; "movies", :action =&amp;gt; "new_movie"})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem that I had initially overlooked was that since Rails compiles the code from top to bottom, it was sending me to the "/movies/:id" when I was trying to use the "/movies/new" path, thinking that "new" was the movie's id. In the program, it was trying to look up a movie with the id of "new", which it would never find, and ended up giving me an error.&lt;/p&gt;

&lt;p&gt;Eventually, after multiple changes and continually hitting the error, I finally realized the problem was the route order. Rearranging the routes in the following way, everything worked:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  get("/movies", { :controller =&amp;gt; "movies", :action =&amp;gt; "index"})
  get("/movies/new", {:controller =&amp;gt; "movies", :action =&amp;gt; "new_movie"})
  get("/movies/:id", { :controller =&amp;gt; "movies", :action =&amp;gt; "movie"})
  get("/delete_movie/:id", { :controller =&amp;gt; "movies", :action =&amp;gt; "delete"})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Keyword Parameters</title>
      <dc:creator>mpuchyr</dc:creator>
      <pubDate>Wed, 05 Oct 2022 20:46:06 +0000</pubDate>
      <link>https://dev.to/mpuchyr/keyword-parameters-hi9</link>
      <guid>https://dev.to/mpuchyr/keyword-parameters-hi9</guid>
      <description>&lt;p&gt;Named parameters specifying values within a method.&lt;/p&gt;

&lt;p&gt;Method with regular parameters:&lt;br&gt;
do_something(a, b)&lt;/p&gt;

&lt;p&gt;Method with named parameters:&lt;br&gt;
do_something(first_thing:, second_thing:)&lt;/p&gt;

&lt;p&gt;In the example with the keyword parameters, the user has a clearer idea of what the arguments sent to the method are used for.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
