<?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>ruby Archives - Suhas Tech</title><link>https://suhastech.com/</link><description>I has tech!</description><atom:link rel="self" type="application/rss+xml" href="https://suhastech.com/category/ruby/feed/"/>
  <item><title>Preheat or generate fragment cache on deploy – Rails 5</title><link>https://suhastech.com/preheat-generate-fragment-cache-deploy-rails-5/</link><guid isPermaLink="false">http://suhastech.com/?p=2413</guid><pubDate>Fri, 05 Jan 2018 15:20:12 GMT</pubDate><dc:creator>Suhas</dc:creator><description>&lt;p&gt;If you have a page that takes a lot of time to generate the cache. The first user who stumbles upon it is in pain. Sometimes it times out before it gets generated completed. &lt;/p&gt;
&lt;p&gt;So, I created a method in one of the helper class&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;br&gt;
    def self.recreate_cache&lt;/code&gt;&lt;/p&gt;&lt;code&gt;
&lt;p&gt;        the_controller = ActionController::Base.new&lt;br&gt;
        # Set any instance variables required by your partial in the controller,&lt;br&gt;
        # they will be passed to the partial with the view_context reference&lt;br&gt;
        the_controller.instance_variable_set &quot;@users&quot;, User.all&lt;/p&gt;
&lt;p&gt;        view_renderer = ActionView::Renderer.new the_controller.lookup_context&lt;br&gt;
        view_renderer.render the_controller.view_context, {template: &apos;users/index.html.erb&apos;}&lt;/p&gt;
&lt;/code&gt;&lt;p&gt;&lt;code&gt;    end&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This will render all the fragment cache. &lt;/p&gt;
&lt;p&gt;Hook this code in capistrano’s deploy method and it should be able to generate it every time you deploy. You could wrap it in a delayed job if you need your deploys faster.&lt;/p&gt;</description></item>
  <item><title>[Fix] PG::CharacterNotInRepertoire: ERROR: invalid byte sequence for encoding “UTF8”</title><link>https://suhastech.com/fix-pgcharacternotinrepertoire-error-invalid-byte-sequence-for-encoding-utf8/</link><guid isPermaLink="false">http://suhastech.com/?p=2408</guid><pubDate>Tue, 10 Mar 2015 16:37:54 GMT</pubDate><dc:creator>Suhas</dc:creator><description>&lt;p&gt;I was trying to store Random IVs generated for AES encryption but couldn’t store them into a PostgreSQL database.&lt;/p&gt;
&lt;p&gt;The Random IVs generated were binary data. So, you have to escape them.&lt;/p&gt;
&lt;p&gt;While storing, do this&lt;/p&gt;
&lt;p&gt;PGconn.escape_bytea(data)&lt;/p&gt;
&lt;p&gt;While retrieving, do this&lt;/p&gt;
&lt;p&gt;PGconn.unescape_bytea(data)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item>
  <item><title>How to install Ruby 1.9.2 on Ubuntu using RVM</title><link>https://suhastech.com/how-to-install-ruby-1-9-2-on-ubuntu-using-rvm/</link><guid isPermaLink="false">http://suhastech.com/?p=2061</guid><pubDate>Wed, 02 May 2012 14:17:08 GMT</pubDate><dc:creator>Suhas</dc:creator><description>&lt;p&gt;Here’s a quick snippet to install Ruby on your Ubuntu system. RVM = Awesomeness!&lt;/p&gt;
&lt;p&gt;login as single user, not root.&lt;/p&gt;
&lt;pre class=&quot;brush: plain; title: ; notranslate&quot; title=&quot;&quot;&gt;bash -s stable &amp;lt; &amp;lt;(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
echo &apos;[[ -s &quot;$HOME/.rvm/scripts/rvm&quot; ]] &amp;amp;&amp;amp; . &quot;$HOME/.rvm/scripts/rvm&quot; # Load RVM function&apos; &amp;gt;&amp;gt; ~/.bashrc
source ~/.bashrc
&lt;/pre&gt;
&lt;p&gt;Check out the requirement packages&lt;/p&gt;
&lt;pre class=&quot;brush: plain; title: ; notranslate&quot; title=&quot;&quot;&gt;rvm requirements 
&lt;/pre&gt;
&lt;p&gt;install the packages using sudo apt-get install ..&lt;/p&gt;
&lt;pre class=&quot;brush: plain; title: ; notranslate&quot; title=&quot;&quot;&gt;rvm install 1.9.2
&lt;/pre&gt;
&lt;p&gt;Takes a lot of time&lt;/p&gt;
&lt;p&gt;then to start using it&lt;/p&gt;
&lt;pre class=&quot;brush: plain; title: ; notranslate&quot; title=&quot;&quot;&gt;rvm use 1.9.2
[code]
if you want to load ruby as soon as you login 
echo &apos;rvm use 1.9.2 # Load Ruby&apos; &amp;gt;&amp;gt; ~/.bashrc
&lt;/pre&gt;</description></item>
</channel></rss>
