<?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[ruby-rails-tips - Medium]]></title>
        <description><![CDATA[Everything Related to Ruby Programming Language - Medium]]></description>
        <link>https://medium.com/ruby-rails-tips?source=rss----e0026e50c459---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>ruby-rails-tips - Medium</title>
            <link>https://medium.com/ruby-rails-tips?source=rss----e0026e50c459---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 09:53:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/ruby-rails-tips" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Perils of Over Engineering]]></title>
            <link>https://medium.com/ruby-rails-tips/perils-of-over-engineering-6b238ab8b09a?source=rss----e0026e50c459---4</link>
            <guid isPermaLink="false">https://medium.com/p/6b238ab8b09a</guid>
            <category><![CDATA[engineering-mangement]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <dc:creator><![CDATA[Ideakart]]></dc:creator>
            <pubDate>Sun, 19 Jun 2022 14:43:36 GMT</pubDate>
            <atom:updated>2022-06-19T14:43:35.960Z</atom:updated>
            <content:encoded><![CDATA[<p>As an engineer working mostly with startups over a decade, what I have realised is that too many of them are over engineering. And some of them really didn’t needed them. If you are from tech, you would definitely know what I mean. They over engineer to the point that it becomes difficult for them to continue.</p><p>There might come a point where you want to move away from monolith to micro-services, but don’t do it because that’s the ‘it’ thing right now.</p><p>Over engineering leads to multiple problems like cost, hiring, loosing the real sight of the problem, managing people and many more. I am just listing down the issues which I have lived through personally. I am writing this so that the new startup founders don’t fall into this trap early. You will know when you need it, just put the monitoring in place.</p><h3>Cost</h3><p>As the best practices for engineering like CI, CD, Scalability, Elasticity and all the `-ilities` of software architecture, all have substantial cost associated with them. If you are not careful the cost can start giving you headaches, choose very carefully and invest wisely. Your processes should do justice to the money you are investing.</p><h3>Hiring</h3><p>Hiring is not easy, and the retention is even harder. As you start to over engineer you will start to move to micro-services, any one who has worked on micro-services know how hard they are to manage, how many people it needs even for a small domain. And specifically the agility comes from having teams working on their respective domains. But if done earlier then needed, it can lead to chaos.</p><h3>Loosing Real Goal</h3><p>The real goal of a startup is to be profitable, this charade of we need scale/funding to be profitable is not true in most of the cases. Yet we do it. If your entire team is focused on scaling, however, if that is not aligned with the profit making, then something is really wrong.</p><p>I have found very few people who care about the `why`, but more who care about the `what`. If you have people in your org belonging to second group, make sure you create a culture where they can start to move to the first approach.</p><p>All big companies, we hear of like Amazon, Netflix and others, only moved to those architectures, because there was a need. Don’t make it a necessity, like them you will also know when to do it, until then focus on profit and building great team culture.</p><p>I know as an engineer, our heart tells us to learn new things always, but that should be in alignment with the business, focusing on both early on, can make you lose both.</p><h4>Again I am reiterating, do it only when you need it, not after not before.</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b238ab8b09a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ruby-rails-tips/perils-of-over-engineering-6b238ab8b09a">Perils of Over Engineering</a> was originally published in <a href="https://medium.com/ruby-rails-tips">ruby-rails-tips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Merge Sort Implementation in Ruby]]></title>
            <link>https://medium.com/ruby-rails-tips/merge-sort-implementation-in-ruby-e7af65a6a87d?source=rss----e0026e50c459---4</link>
            <guid isPermaLink="false">https://medium.com/p/e7af65a6a87d</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Ideakart]]></dc:creator>
            <pubDate>Sat, 07 May 2022 08:36:35 GMT</pubDate>
            <atom:updated>2022-05-07T08:38:55.263Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f35f57cacf6e0df78d96b8ac1494daf/href">https://medium.com/media/5f35f57cacf6e0df78d96b8ac1494daf/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7af65a6a87d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ruby-rails-tips/merge-sort-implementation-in-ruby-e7af65a6a87d">Merge Sort Implementation in Ruby</a> was originally published in <a href="https://medium.com/ruby-rails-tips">ruby-rails-tips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Importing database dump in Ruby on Rails]]></title>
            <link>https://medium.com/ruby-rails-tips/importing-database-dump-in-ruby-on-rails-4591ff80e9e1?source=rss----e0026e50c459---4</link>
            <guid isPermaLink="false">https://medium.com/p/4591ff80e9e1</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[rails-import]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Ideakart]]></dc:creator>
            <pubDate>Tue, 10 Aug 2021 14:16:19 GMT</pubDate>
            <atom:updated>2023-07-05T17:47:14.798Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes, we need to load the data from sandbox environments, production environments into our local application.<br>We generally get a dump.tar.gz or zipped file, let’s see how we can import the data.<br>1. Unzip the data.<br>2. Drop the database that you have in your local, you can drop it in two ways<br> a. rails db:drop<br> b. You can login to your database like for e.g if you are using psql, just type psql, then do drop mydatabase .<br>3. Now we need to create the database. Again from rails directory you can do either <br> a. rails db:create <br> b. create mydatabase .<br>4. Now you can load your unzipped database by doing either of the given below steps<br> a.rails db &lt; mydatadump <br> b.psql -u username -p password mydatabase &lt; mydatadump</p><p>You can go with either approaches i.e. both works. This is to unlock beginners from not getting stuck with the data import.</p><p>Also, you can checkout the below video to see the above in action.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJdzycr0QJWE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJdzycr0QJWE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJdzycr0QJWE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae297937ebdd238f82bd191051cc82fe/href">https://medium.com/media/ae297937ebdd238f82bd191051cc82fe/href</a></iframe><p>While writing this got to see other alternatives also, follow<br><a href="https://stackoverflow.com/questions/8342642/how-can-i-import-a-sql-file-into-a-rails-database/28874165">https://stackoverflow.com/questions/8342642/how-can-i-import-a-sql-file-into-a-rails-database/28874165</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4591ff80e9e1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ruby-rails-tips/importing-database-dump-in-ruby-on-rails-4591ff80e9e1">Importing database dump in Ruby on Rails</a> was originally published in <a href="https://medium.com/ruby-rails-tips">ruby-rails-tips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling Amp Login in Production]]></title>
            <link>https://medium.com/ruby-rails-tips/handling-amp-login-in-production-b9d585a9f900?source=rss----e0026e50c459---4</link>
            <guid isPermaLink="false">https://medium.com/p/b9d585a9f900</guid>
            <category><![CDATA[amp]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[caching-issues]]></category>
            <dc:creator><![CDATA[Ideakart]]></dc:creator>
            <pubDate>Wed, 04 Sep 2019 11:26:28 GMT</pubDate>
            <atom:updated>2019-09-04T11:26:28.159Z</atom:updated>
            <content:encoded><![CDATA[<h3>Handling Logged in Users in Amp</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*DL38tKzd5i0Eu6RiW-Nmtg.jpeg" /><figcaption>Amp-Project</figcaption></figure><p>Amp is all well and good for serving the pages at a fast pace, google maintains cache at its own and serve the pages faster, however, you can’t use the Jquery or vanilla Java-script. For login you can just redirect them to signin/signup(non-amp), but when the users come back on amp pages, you want to see them as logged in, right. But there is no way to do that except for these tags.</p><p>These tags can help you manage the state of the user via the use of simple API’s.</p><ol><li>amp-access</li><li>amp-mustache</li></ol><p><a href="https://amp.dev/documentation/components/amp-access/">amp-access</a> — Basically a way for you to configure if else conditions along with the other variables needed for rendering the authorization part.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1597e85d8d230b57e870a406765b4af/href">https://medium.com/media/e1597e85d8d230b57e870a406765b4af/href</a></iframe><p>The authorization key in the above snippet basically calls the api while the page is getting loaded, you can return the variables in the form of json, for e.g. I am returning</p><p>{<br> “error”: false,<br> “loggedIn”: true,<br> “powerUser”: false,<br> “name”: current_user.name,<br> “image”: current_user.asset.url(https://medium.com/:thumb)<br> }</p><p>If there is an issue with the api, it fallback to default parameters(authorizationFallbackResponse).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f168a1b2d1aa3ef770a15f798a768d14/href">https://medium.com/media/f168a1b2d1aa3ef770a15f798a768d14/href</a></iframe><p>2. <a href="https://amp.dev/documentation/components/amp-mustache/">amp-mustache</a></p><p>This will help you in binding the variables you sent and assign it to the template, without this your variables won’t bind.</p><p>Just put the above in the html and see the magic, the user will be logged in and you will be able to see the image.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9d585a9f900" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ruby-rails-tips/handling-amp-login-in-production-b9d585a9f900">Handling Amp Login in Production</a> was originally published in <a href="https://medium.com/ruby-rails-tips">ruby-rails-tips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amp-Caching and Updation in Rails]]></title>
            <link>https://medium.com/ruby-rails-tips/amp-caching-and-updation-in-rails-51b674160085?source=rss----e0026e50c459---4</link>
            <guid isPermaLink="false">https://medium.com/p/51b674160085</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[amp-cache]]></category>
            <category><![CDATA[data-updation]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Ideakart]]></dc:creator>
            <pubDate>Tue, 27 Aug 2019 10:33:11 GMT</pubDate>
            <atom:updated>2019-08-27T10:33:11.724Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*DL38tKzd5i0Eu6RiW-Nmtg.jpeg" /></figure><p>Amp Cache can really load your pages faster when a user clicks on google results, one reason being the limit on 50,000 bytes and no java-script support.</p><p>Now you can add support for amp by just adding an amp extension in your rails app and you can use the following components.</p><p><a href="https://amp.dev/documentation/components/?format=websites">Components</a></p><p>That being said, one problem is that once you update your page, how do you update the cached page on google servers.</p><p>Now you can definitely read about it here:</p><p><a href="https://developers.google.com/amp/cache/update-cache">Update AMP Content | Google AMP Cache | Google Developers</a></p><p>For e.g. I own this domain <a href="https://www.ideakart.com/">ideakart.com</a> and update the cache frequently using the code described below.</p><p>Here is the script for updating the cache:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52ef3f928f1bedbe17ac1852c4c82638/href">https://medium.com/media/52ef3f928f1bedbe17ac1852c4c82638/href</a></iframe><ol><li>You can generate the public and private keys by using this:</li></ol><pre>openssl genrsa 2048 &gt; private-key.pem<br>openssl rsa -in private-key.pem -pubout &gt;public-key.pem</pre><p>Also add your public file to this location:</p><p><a href="https://example.com/.well-known/amphtml/apikey.pub">https://example.com/.well-known/amphtml/apikey.pub</a></p><p><strong>2. `echo -n &gt;url.txt “/update-cache/c/s/www.ideakart.com#{url}?amp_action=flush&amp;amp_ts=#{ts}&quot; &amp;&amp; cat url.txt | openssl dgst -sha256 -sign private-key.pem &gt;signature.bin`</strong></p><p>This line basically copies your code to url.txt and then sign it with the help of the private key generated.</p><p>3. Then encode signature bin using base64 using:</p><p>amp_signature = Base64.urlsafe_encode64(File.read(“signature.bin”))</p><p>4. Then just update the cache by hitting wget or curl:</p><p>`wget -q — spider “<a href="https://www-ideakart-com.cdn.ampproject.org/update-cache/c/s/www.ideakart.com#{url}?amp_action=flush&amp;amp_ts=#{ts}&amp;amp_url_signature=#{amp_signature">https://www-ideakart-com.cdn.ampproject.org/update-cache/c/s/www.ideakart.com#{url}?amp_action=flush&amp;amp_ts=#{ts}&amp;amp_url_signature=#{amp_signature</a>}&quot;`</p><p>That’s it, it will update the amp cache on google.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51b674160085" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ruby-rails-tips/amp-caching-and-updation-in-rails-51b674160085">Amp-Caching and Updation in Rails</a> was originally published in <a href="https://medium.com/ruby-rails-tips">ruby-rails-tips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimization of Rails Web Site using webp]]></title>
            <link>https://medium.com/ruby-rails-tips/optimization-of-rails-web-site-using-webp-7b9fa1e7aea3?source=rss----e0026e50c459---4</link>
            <guid isPermaLink="false">https://medium.com/p/7b9fa1e7aea3</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[webp]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Ideakart]]></dc:creator>
            <pubDate>Thu, 28 Mar 2019 08:12:12 GMT</pubDate>
            <atom:updated>2022-03-27T16:55:42.243Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7kRYicutRc-cpJ6XI8lJ9A.png" /></figure><p>We all know google loves webp images and even gives them a higher ranking, but how do you upload webp images when all you have uploaded are jpg and png’s, one thing is to convert all the images that you had in your buckets, move to webp for the supported browsers.</p><p>But how do you do that?</p><p>In my case I was using paperclip gem for uploading files to s3, and had png’s and jpeg’s in my bucket. The requirement was to have webp for each image too, show webp in the browsers supporting webp and show jpg’s or png’s in non supporting browsers.</p><p>Now there are two things to keep in mind</p><ol><li>How do you convert images from one format to another?</li><li>How do you ensure web browsers pick webp f they support it and pick different format if not supported.</li></ol><p><strong>How do you convert images from one format to another?</strong></p><p>If you have worked with paperclip before, you can recognize the below given file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5a484adc78162d77083efe3be4385ed/href">https://medium.com/media/f5a484adc78162d77083efe3be4385ed/href</a></iframe><p>So nothing different much in the post class except we have a</p><p><strong>:processors =&gt; [:webp]</strong></p><p>option, which basically tells it to pick up the defined processor, now we want that to apply the processing to happen only in case of images where we want webp.</p><p><strong>only_process: [:webp]</strong></p><p>We also want to store the original files, so nothing in styles there</p><p><strong>original: []</strong></p><p>Now coming to the webp processor, it is getting initialized using super, so which in turns is calling this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd648b399800ecf311035cb838bc5534/href">https://medium.com/media/fd648b399800ecf311035cb838bc5534/href</a></iframe><p>Read the comments in the procecssor.rb to understand what we did in our custom webp processor.</p><p><strong>How do you ensure web browsers pick webp f they support it and pick different format if not supported.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddcce52c5f62399effe1fce96af62b33/href">https://medium.com/media/ddcce52c5f62399effe1fce96af62b33/href</a></iframe><p>This code basically tells the browser to pick the webp format(first source element), if the browser supports it, if not just go ahead and pick the image from the second source element.</p><p>So, that’s about it, by this process you can definitely convert image to any format, you can just change this line:</p><p>“convert #{fromfile} -quality 50 #{tofile(temp_file)}” in webp class.</p><p>Thanks.</p><p>If you are a Ruby Developer, do register on <a href="https://jobemon.com/">https://jobemon.com</a> for getting access to awesome jobs</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b9fa1e7aea3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ruby-rails-tips/optimization-of-rails-web-site-using-webp-7b9fa1e7aea3">Optimization of Rails Web Site using webp</a> was originally published in <a href="https://medium.com/ruby-rails-tips">ruby-rails-tips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Contributing To Rails]]></title>
            <link>https://medium.com/ruby-rails-tips/contributing-to-rails-2bf5863ab8e?source=rss----e0026e50c459---4</link>
            <guid isPermaLink="false">https://medium.com/p/2bf5863ab8e</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Ideakart]]></dc:creator>
            <pubDate>Fri, 08 Mar 2019 18:00:18 GMT</pubDate>
            <atom:updated>2022-01-06T15:45:13.912Z</atom:updated>
            <content:encoded><![CDATA[<h3>Contributing To Rails | Part 1</h3><p>Writing this doc hoping people make Rails the best framework there is. The objective is to make you understand rails, use it, make it better.</p><p>It’s even the best framework now, no questions there.</p><p>Now coming to the contributing part, how can I add commits to rails repo. There is really good info on how you can contribute to rails on official rails website. These steps if you follow may help you in getting that first issue.</p><ol><li>Look through the current issues in rails Github repo.</li><li>Carefully go through each one of them, see what interests you.</li><li>Now dig deeper into the issue first, and rails community is awesome they even have the reproduction scripts for any bugs submitted.</li><li>Now reproduce it on your local by creating an app or using the scripts.</li><li>Check the trace from where the bug is being caused from.</li><li>Now change the code, commit, make sure to add the test cases.</li><li>Now push it to your forked repo and create a PR.</li><li>Be patient till you get a comment from the core contributors, they are really helpful.</li></ol><p>We will be covering atleast one issue in the next part of this article, Stay Tuned, thanks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bf5863ab8e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ruby-rails-tips/contributing-to-rails-2bf5863ab8e">Contributing To Rails</a> was originally published in <a href="https://medium.com/ruby-rails-tips">ruby-rails-tips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>