<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jigyasa Makkar</title>
	<atom:link href="http://jigyasamakkar.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jigyasamakkar.com</link>
	<description>Ruby on Rails Developer</description>
	<lastBuildDate>Thu, 08 Dec 2011 10:08:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Ruby oci8 with Rails 3.1 on Ubuntu</title>
		<link>http://jigyasamakkar.com/ruby-oci8-with-rails-3-1-on-ubuntu/</link>
		<comments>http://jigyasamakkar.com/ruby-oci8-with-rails-3-1-on-ubuntu/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 10:05:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[oracle 11g]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[ruby-oci8]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://jigyasamakkar.com/?p=380</guid>
		<description><![CDATA[ruby-oci8 is the gem to use Oracle as the database for your Rails 3.1 application. Getting it to work can be a &#8216;little&#8217; tricky. In this post, I&#8217;ll try to summarize how to get it to work on Ubuntu for a Rails 3.1 application. Well, let&#8217;s start with the basics. Before you try your luck [...]]]></description>
			<content:encoded><![CDATA[<p>ruby-oci8 is the gem to use Oracle as the database for your Rails 3.1 application. Getting it to work can be a &#8216;little&#8217; tricky. In this post, I&#8217;ll try to summarize how to get it to work on Ubuntu for a Rails 3.1 application.</p>
<p>Well, let&#8217;s start with the basics. Before you try your luck with the magnificent &#8216;bundle install&#8217;,  halt! Stop right there and do THIS first <img src='http://jigyasamakkar.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>1. Install Oracle Instantclient. Get started with that <a href="http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html">here</a>. Its pretty straightforward and shouldn&#8217;t be a problem.</p>
<p>2. Post that, you need to set the environment variable LD_LIBRARY_PATH. Do it now by typing in :</p>
<p><code>export LD_LIBRARY_PATH="/usr/lib/oracle/11.2/client64/"</code></p>
<p>in your user profile file ie &#8216;.bashrc&#8217; or &#8216;.bash_profile&#8217;. Reload it by typing:</p>
<p><code>source .bashrc</code></p>
<p>Also, check that this location does have the client installed. If not, find out where it is and create a soft link to here. ruby-oci8 expects to find it at this location &#8220;/usr/lib/oracle/&#8230;.&#8221;.</p>
<p>3. Lastly, set this link:</p>
<p><code>sudo ln -s /usr/include/linux/ /usr/include/sysclient</code></p>
<p>One more thing, try typing:</p>
<p><code>echo $ORACLE_HOME</code></p>
<p>It should be set to where your Oracle is installed. If it isn&#8217;t set, set it in your user profile file again with &#8216;export&#8217;.</p>
<p>That&#8217;s it. We are done. Try running &#8216;<code>bundle install</code>&#8216; or &#8216;<code>gem install ruby-oci8</code>&#8216; and it should work. Well, it should. If it didn&#8217;t, well, I&#8217;m sure its Oracle, not you <img src='http://jigyasamakkar.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  In any case, drop in a comment and maybe I can help. For the rest of the &#8216;process&#8217;, I&#8217;ve written a follow up post <a href="http://jigyasamakkar.com/oracle-11g-on-ubuntu-for-rails-3/">here</a>. Happy DBing <img src='http://jigyasamakkar.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://jigyasamakkar.com/ruby-oci8-with-rails-3-1-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle 11g on Ubuntu for Rails 3</title>
		<link>http://jigyasamakkar.com/oracle-11g-on-ubuntu-for-rails-3/</link>
		<comments>http://jigyasamakkar.com/oracle-11g-on-ubuntu-for-rails-3/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 12:01:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[database.yml]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[oracle 11g]]></category>
		<category><![CDATA[rails 3]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://jigyasamakkar.com/?p=338</guid>
		<description><![CDATA[Developers don&#8217;t like databases (usually). Especially enterprise-y ones (read Oracle). I started my career as a DBA and shockingly enough, I happen to enjoy working on DBs. That said, this write-up is originally for my current project team and it works out for all developers &#8216;forced&#8217; to work on Oracle for their clients. This one [...]]]></description>
			<content:encoded><![CDATA[<div>Developers don&#8217;t like databases (usually). Especially enterprise-y ones (read Oracle). I started my career as a DBA and shockingly enough, I happen to enjoy working on DBs. That said, this write-up is originally for my current project team and it works out for all developers &#8216;forced&#8217; to work on Oracle for their clients. This one is NOT for DBAs, or anyone who can easily find their way around Oracle without frowning.</div>
<div>That said, let&#8217;s get to the meat. Recently, I set up an Ubuntu box with Oracle 11g to work with Rails 3.1. How I got the ruby-oci8 gem working is another story altogether. (which I&#8217;ve narrated <a href="http://jigyasamakkar.com/ruby-oci8-with-rails-3-1-on-ubuntu/">here</a>) But (if and) when your &#8216;bundle install&#8217; completes successfully and you come to the configurations further, you read this article and get those done with ease (hopefully).</div>
<div>To begin with, navigate to Oracle admin Web interface:</div>
<div style="text-align: left;"><a href="http://127.0.0.1:8080/apex/apex_admin">http://127.0.0.1:8080/apex/apex_admin</a></div>
<div>The username is always &#8216;<strong>admin</strong>&#8216; and the password is the one you set while installing Oracle. You would be prompted to change the password. Post that, you see an interface like this:</div>
<div><a href="http://jigyasamakkar.com/wp-content/uploads/2011/11/oracle_admin_web_interface1.png"><img class="size-full wp-image-346 aligncenter" title="oracle_admin_web_interface" src="http://jigyasamakkar.com/wp-content/uploads/2011/11/oracle_admin_web_interface1.png" alt="Oracle 11g Web Admin Interface" width="600" height="400" /></a></div>
<div>Now, the actual navigation begins. Go to:</div>
<div><strong>Manage Workspaces</strong> -&gt; <strong>Create Workspace</strong> -&gt; Fill in a schema name, password, email etc. Hit Create.</div>
<div>It shows a confirmation for creation. A page with all the details is displayed. For the love of God, <strong>save it</strong>! Copy it and save it somewhere safe.</div>
<div>Now, you can (finally) proceed with the Rails database.yml configuration, if you are done with ruby-oci8 installation). It looks something like this (for development):</div>
<blockquote>
<div>development:</div>
<div>adapter: oracle_enhanced</div>
<div>host: localhost</div>
<div>database: xe</div>
<div>username: &lt;schema_name&gt;</div>
<div>password: &lt;workspace_password&gt;</div>
</blockquote>
<div>Try <strong>rake db:migrate</strong> (<strong>not create</strong>). It should work. If it doesn&#8217;t, comment below and maybe I can help you debug it.</div>
<div>That went well. But of course it isn&#8217;t over. You would want different &#8216;databases&#8217; for development and test. Now, to create another &#8216;database&#8217;, you actually need to setup another schema. Lets go through that now. Go to the web admin again:</div>
<div><strong>Manage Workspaces</strong> -&gt;<strong> Manage Workspace to Schema Assignments </strong>-&gt; <strong>Create</strong></div>
<div><strong>New</strong> -&gt; <strong>Next</strong> -&gt; (Select a <strong>workspace</strong> from existing workspaces) -&gt; <strong>Next</strong></div>
<div>Give a <strong>schema</strong> name, <strong>password</strong>, <strong>default tablespace</strong> (select from an existing) -&gt;<strong> temporary tablespace</strong> (select &#8216;<strong>TEMP</strong>&#8216; from the list) -&gt; Next -&gt; Confirm</div>
<div>Again, in the database.yml:</div>
<div>
<blockquote>
<div>test:</div>
<div>adapter: oracle_enhanced</div>
<div>host: localhost</div>
<div>database: xe</div>
<div>username: &lt;new_schema_name&gt;</div>
<div>password: &lt;schema_password&gt;</div>
</blockquote>
</div>
<div>Try rake db:migrate RAILS_ENV=test. It should work. Proceed with creating as many &#8216;databases&#8217; (schemas) as you need.</div>
<div>All this was fun and nice (well, it wasn&#8217;t that bad), but there are some known pitfalls which I can pre-inform you about. Invariably, you will end up needing the command line for some admin commands. Here&#8217;s how you get to it. Go to the path where Oracle is installed from the Terminal. If unsure, fire:</div>
<blockquote>
<div>&gt; echo $ORACLE_HOME</div>
</blockquote>
<div>That&#8217;s where you &#8216;<strong>cd</strong>&#8216; to. Going further ahead , go to :</div>
<blockquote>
<div>&gt; cd &lt;$ORACLE_HOME&gt;/product/11.2.0/xe/bin</div>
</blockquote>
<div>If you &#8216;ls&#8217; into it, you can see &#8216;sqlplus&#8217;. Type in:</div>
<blockquote>
<div>&gt; sqlplus</div>
<div>user-name: / as sysdba</div>
<div>password: &lt;password to login to web interface used with username &#8216;admin&#8217;&gt; (if prompted)</div>
<div>SQL&gt; grant dba to &lt;schema_name&gt;;</div>
</blockquote>
<div>The above statement gives dba privileges to your &#8216;user&#8217; (schema) so that commands like &#8216;create database link&#8217; or &#8216;alter tablespace&#8217; etc run smoothly for your user. Now, you can exit and login as your own user.</div>
<blockquote>
<div>SQL&gt; exit</div>
<div>sqlplus</div>
<div>user-name: &lt;schema_name_you granted dba to&gt;</div>
<div>password: &lt;schema password&gt;</div>
</blockquote>
<div>Now you can simply fire away admin commands. For instance, if you want a new tablespace for say indices</div>
<div>
<div>- Creating the tablespace named &#8216;my_tblspc&#8217;:</div>
<blockquote>
<div>CREATE TABLESPACE my_tblspc DATAFILE &#8216;path/to/datafile/my_tblspc.dbf&#8217; size 1024M;</div>
</blockquote>
<div>- If during the course of your work, you get an Oracle error crying for space:</div>
<blockquote>
<div>alter database datafile &#8216;path/to/tablespace/datafile.dbf&#8217; autoextend on;</div>
</blockquote>
<div>* give the path of datafile for the tablespace. Incase there are multiple datafiles, use the last datafile path.</div>
<div>- If the above statement doesn&#8217;t solve it either, add a datafile:</div>
<blockquote>
<div>alter tablespace tablespace_name add datafile &#8216;path/to/file/to/be/created/name.dbf&#8217; size 8192M autoextend on;</div>
</blockquote>
</div>
<div><strong>Tips</strong>:</div>
<div>&gt; Datafiles are located at: $ORACLE_HOME/oradata/XE</div>
<div>&gt; Tablespace name can be found as:</div>
<div><a href="http://127.0.0.1:8080/apex/apex_admin">127.0.0.1:8080/apex/apex_admin</a> -&gt; <strong>Manage Workspaces</strong> -&gt; <strong>Existing Workspaces</strong> -&gt; (Select your <strong>workspace</strong> name) -&gt; Look at workspace schemas section.</div>
<div>Have fun! And remember, Databases don&#8217;t bite <img src='http://jigyasamakkar.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </div>
]]></content:encoded>
			<wfw:commentRss>http://jigyasamakkar.com/oracle-11g-on-ubuntu-for-rails-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mods</title>
		<link>http://jigyasamakkar.com/mods/</link>
		<comments>http://jigyasamakkar.com/mods/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 07:18:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jigyasamakkar.com/?p=314</guid>
		<description><![CDATA[Mobile Developer Summit 2011 is here. It&#8217;s by the people from SaltMarch Media. Two days of back-to-back iOS/Android/WinMo development sessions. Mostly excited about the sessions covering Titanium &#38; Phonegap. I&#8217;ve been working on Corona lately. And although I don&#8217;t see Corona figure anywhere on the Mods2011 Agenda, I&#8217;m still quite excited to explore my options. [...]]]></description>
			<content:encoded><![CDATA[<div><a href="http://www.developermarch.com/mods/index.html"><img class="alignnone" title="Mobile Developer Summit 2011" src="http://www.developermarch.com/mods/image/2011/banner/attendingmods.jpg" alt="Mobile Developer Summit 2011" width="225" height="150" /></p>
<p></a></div>
<div>Mobile Developer Summit 2011 is here. It&#8217;s by the people from SaltMarch Media. Two days of back-to-back iOS/Android/WinMo development sessions. Mostly excited about the sessions covering Titanium &amp; Phonegap. I&#8217;ve been working on Corona lately. And although I don&#8217;t see Corona figure anywhere on the Mods2011 Agenda, I&#8217;m still quite excited to explore my options. By the end, I&#8217;ll either feel reassured about my choice in Corona, or be switching to Titanium/PhoneGap. Good thing, I still haven&#8217;t purchased my Corona SDK license :p. Not that heavily invested in it yet. Also of particular interest are some sessions about Augmented Reality implementations. I have lots of ideas bouncing about in my head, that use AR and the easy availability of high quality camera on mobile phones to get through. Somehow I hope against hope, that they would offer discounts on the Summit tickets for out-of-towners. Or offer a Summit Ticket + Hotel Stay deal <img src='http://jigyasamakkar.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . Bangalore isn&#8217;t inexpensive to travel to, or stay in, this time of the year. I&#8217;m hoping the Summit will be totally worth it. I have some questions about app monetization, that I&#8217;m hoping to have addressed by one of the many experts speaking at the summit. Specially as an Indian developer targeting the Android Marketplace.</div>
<div>Leaving tomorrow morning. Here goes <img src='http://jigyasamakkar.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </div>
]]></content:encoded>
			<wfw:commentRss>http://jigyasamakkar.com/mods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>#delhihack</title>
		<link>http://jigyasamakkar.com/delhihack/</link>
		<comments>http://jigyasamakkar.com/delhihack/#comments</comments>
		<pubDate>Sat, 17 Sep 2011 02:17:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://jigyasamakkar.com/?p=270</guid>
		<description><![CDATA[I&#8217;ve always been convinced about the efficacy of &#8216;hackathons&#8217; &#8211; 24 to 48 hr code marathons, working on an idea or something you feel passionately about. And I&#8217;ve had so many occasions where I almost participated in one, but didn&#8217;t. But, last weekend I finally did get to participate in one and well.. ended up winning it! [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been convinced about the efficacy of &#8216;hackathons&#8217; &#8211; 24 to 48 hr code marathons, working on an idea or something you feel passionately about. And I&#8217;ve had so many occasions where I almost participated in one, but didn&#8217;t. But, last weekend I finally did get to participate in one and well.. ended up winning it! Wohoooo! <img src='http://jigyasamakkar.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>It was the &#8216;Hackers &amp; Founders&#8217; Delhi Hackathon (<a href="http://hfdelhi.in/">http://hfdelhi.in</a>). Organized by the extremely helpful and proactive people at One97 (<a href="http://one97.com/">http://one97.com/</a>) and ClearTax (<a href="http://cleartax.in/">http://cleartax.in/</a>).</p>
<p>But enough with the details. So, here it is &#8211; the award winning &#8216;hack&#8217; <img src='http://jigyasamakkar.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><a href="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0001_Group-1-copy.png"><img class="size-full wp-image-287 alignnone" title="bulletracer_exportCopy_v2_0001_Group-1-copy" src="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0001_Group-1-copy.png" alt="" width="340" height="665" /></a></p>
<h3><strong>SayWhat?</strong></h3>
<p>A cross-platform (iOS/Android) mobile app featuring popular dialogues/sayings from Movies and Sitcoms. The player has to string together popular dialogues, one small piece at a time, with a visual aid from the movie/sitcom helping all along. Its based on a simple idea of finishing sentences in segments. The app was built using Ansca Mobile&#8217;s Corona framework (<a href="http://www.anscamobile.com/corona/">http://www.anscamobile.com/corona</a>) which is an upcoming mobile development platform that builds on top of both RoR and Javascript. Two of my favorite tools <img src='http://jigyasamakkar.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>A few screenshots from the quick prototype built at the hackathon.</p>
<p><a href="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0005_Layer-1.png"><img class="alignleft size-full wp-image-277" title="bulletracer_exportCopy_v2_0005_Layer-1" src="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0005_Layer-1.png" alt="" width="198" height="387" /></a><a href="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0004_Layer-3.png"><img title="bulletracer_exportCopy_v2_0004_Layer-3" src="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0004_Layer-3.png" alt="" width="198" height="387" /></a></p>
<p><a href="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0005_Layer-1.png"></a> <a href="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0004_Layer-3.png"></a><a href="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0006_Layer-4.png"><img class="alignleft size-full wp-image-279" title="bulletracer_exportCopy_v2_0006_Layer-4" src="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0006_Layer-4.png" alt="" width="198" height="387" /></a><a href="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0003_Layer-5.png"><img class="alignleft size-full wp-image-280" title="bulletracer_exportCopy_v2_0003_Layer-5" src="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0003_Layer-5.png" alt="" width="198" height="387" /></a><a href="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0002_Layer-7.png"><img class="size-full wp-image-281 alignnone" title="bulletracer_exportCopy_v2_0002_Layer-7" src="http://jigyasamakkar.com/wp-content/uploads/2011/09/bulletracer_exportCopy_v2_0002_Layer-7.png" alt="" width="196" height="384" /></a></p>
<p>I have since, refactored and cleaned up code keeping in mind an eventual Google Marketplace/Apple Store release. Post-feedback from friends and some co-participants from the hackathon, I have been tweaking and adjusting game play trying to find the right balance between ease of play and challenge goals. The scoring criteria is a constant work in progress, as we discover the reward to effort ratio, as players ourselves. A few friends have been set in motion, hand picking the absolute best of known movie/sitcom quotes and I am hoping to be able to have a database of at least 500 quotes for the soft launch. The app UI is also being given some tactile love with details, small animations and audio feedback. Corona has amazing support for Facebook integration, and an &#8216;Extend challenge&#8217;/'Post Score&#8217; optional functionality seems like an appropriate add-on by the time I manage to take this to the stores.</p>
<p>Anxious to see this listed on the app stores real soon. Say what?! <img src='http://jigyasamakkar.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://jigyasamakkar.com/delhihack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jqGrid &#8211; Inline Edit woes</title>
		<link>http://jigyasamakkar.com/jqgrid-inline-edit-woes/</link>
		<comments>http://jigyasamakkar.com/jqgrid-inline-edit-woes/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 17:07:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[edit]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[inline]]></category>
		<category><![CDATA[inline edit]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[jqGrid]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery grid]]></category>
		<category><![CDATA[prevent restoreRow]]></category>

		<guid isPermaLink="false">http://jigyasamakkar.com/?p=260</guid>
		<description><![CDATA[I&#8217;ve been working quite extensively with jqGrid. Its nicely done, very flexible and is documented decently enough. That said, it does have its fair share of issues. Some issues involve spelling mistakes, even. But I&#8217;ve moved past all those and hit a big solid roadblock on the jqGrid Inline Edit. The default behavior of inline [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working quite extensively with <a href="http://www.trirand.com/blog/">jqGrid</a>. Its nicely done, very flexible and is documented decently enough. That said, it does have its fair share of issues. Some issues involve spelling mistakes, even.</p>
<p>But I&#8217;ve moved past all those and hit a big solid roadblock on the <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing">jqGrid Inline Edit</a>. The default behavior of inline editing is that if the edited row saves successfully with no errors, the grid can reload and reflect the newly updated record. If however, the server side validations (onSubmit aka Enter key press) failed, the edited row is restored to its last saved state, in non-edit mode. This results in the loss of any valid editing that the user has already done. You can read more about the problem <a href="http://stackoverflow.com/questions/4668167/prevent-restoring-row-if-error-was-rised-while-editing">here</a>.</p>
<p>After struggling a bit and reading through the &#8216;grid.inlinedit.js&#8217; file, I discovered this bit of code:<br />
<code><br />
editRow : function(rowid,keys,oneditfunc,successfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc) {<br />
// Compatible mode old versions<br />
var settings = {<br />
"keys" : keys || false,<br />
"oneditfunc" : oneditfunc || null,<br />
"successfunc" : successfunc || null,<br />
"url" : url || null,<br />
"extraparam" : extraparam || {},<br />
"aftersavefunc" : aftersavefunc || null,<br />
"errorfunc": errorfunc || null,<br />
"afterrestorefunc" : afterrestorefunc|| null,<br />
"restoreAfterErorr" : true<br />
},<br />
args = $.makeArray(arguments).slice(1), o;</code></p>
<p><code> </code></p>
<p><code> if(args[0] &amp;&amp; typeof(args[0]) == "object" &amp;&amp; !$.isFunction(args[0])) {<br />
o = $.extend(settings,args[0]);<br />
} else {<br />
o = settings;<br />
}<br />
// End compatible</code></p>
<p>What this really does is, introduces a backdoor solution to our problem. To be specific, the problem here is the &#8216;restoreAfterError&#8217; parameter which is hardcoded as &#8216;true&#8217;. This attribute is responsible for the problem above. It forces the execution of the method that restores the errored out row. So, this attribute needs to be set to &#8216;false&#8217; to let the errored out row remain in editable state with all changed values intact.</p>
<p>To do this, I did not want to change the signature of the &#8216;editRow&#8217; method. And thankfully, I didn&#8217;t need to. Instead of the usual call :</p>
<p><code><br />
jQuery("#grid_id").jqGrid('editRow',rowid, keys, oneditfunc, succesfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc);</code></p>
<p>Invoke the method like this instead:<br />
<code><br />
grid.jqGrid('editRow', rowId, {"keys":true, "oneditfunc":"", "successfunc":Mmd.Callbacks.SuccessEdit, "url":url, "extraparam":{'_method': 'PUT'}, "aftersavefunc":Mmd.Callbacks.ReloadGrid, "errorfunc":Mmd.Callbacks.Error, "restoreAfterError":false});</code></p>
<p>This invocation sets the &#8216;args[0]&#8216; as an object (json: with &#8216;keys&#8217; as the first key) and hence satisfies the &#8216;if&#8217; condition. The &#8216;if&#8217; path then sets the options as the json we send during method invocation. And this json sets the desired &#8216;restoreAfterError&#8217; to false.</p>
<p>Okay, so step 1 done. Phew! Now that&#8217;s only half the battle won. The second issue is that once the errored row stays in editable mode, it cannot be saved again by hitting &#8216;Enter&#8217;. Read more about this problem <a href="http://www.trirand.com/blog/?page_id=393/discussion/inline-edit-how-to-save-row-again-after-404-error-is-returned/">here</a>.</p>
<p>Now the solution to this is tricky. It involves commenting out (or deleting!) this line of code:<br />
<code><br />
$(ind).unbind("keydown");</code></p>
<p>This is line #274 for me and is a part of &#8216;saveRow&#8217; method definition in the &#8216;grid.inlineedit.js&#8217; file. Take this line out and the &#8216;Enter&#8217; key stays bound to the errored out row now in editable mode to correct the error and save again.</p>
<p>Hope this helps <img src='http://jigyasamakkar.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://jigyasamakkar.com/jqgrid-inline-edit-woes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dynamic is_ ? methods for boolean attributes of a  model</title>
		<link>http://jigyasamakkar.com/dynamic-is_-methods-for-boolean-attributes-of-a-model/</link>
		<comments>http://jigyasamakkar.com/dynamic-is_-methods-for-boolean-attributes-of-a-model/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 13:03:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[dynamic methods]]></category>
		<category><![CDATA[meta programming]]></category>
		<category><![CDATA[metaprogramming]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://jigyasamakkar.com/?p=214</guid>
		<description><![CDATA[A very common pattern observed in Rails models is a series of &#8220;is_{attribute}?&#8221; instance methods. Here, &#8216;attribute&#8217; is usually a boolean column. I got tired of defining these similar methods. And adding to the misery, if the model structure changes to add another boolean field, you need to define another clone of the same method! [...]]]></description>
			<content:encoded><![CDATA[<p>A very common pattern observed in Rails models is a series of &#8220;is_{attribute}?&#8221; instance methods. Here, &#8216;attribute&#8217; is usually a boolean column. I got tired of defining these similar methods. And adding to the misery, if the model structure changes to add another boolean field, you need to define another clone of the same method!</p>
<p>So, I ended up using this little trick. Ruby meta programming awesomeness helped, of course.</p>
<p>Consider a minimalistic Model called &#8216;User&#8217; with an underlying &#8216;users&#8217; table in the database. </p>
<p><code><strong>User</strong><br />
Id, Login, Name, Email, Verified, Blocked, Available </code></p>
<p>I know the schema can be altered to take these 3 into a single field called &#8220;state&#8221; or something on those lines, but this is just a simple example. Here, the last 3 attributes are boolean. We need to define methods &#8220;is_verified?&#8221; , &#8220;is_blocked?&#8221; , &#8220;is_available?&#8221;. </p>
<p>Usually, we would define 3 instance methods or named_scopes to achieve the objective. Like so:<br />
<code><br />
  def is_verified?<br />
    self.verified<br />
  end</p>
<p>  def is_blocked?<br />
    self.blocked<br />
  end</p>
<p>  def is_available?<br />
    self.available<br />
  end<br />
</code></p>
<p>Annoying, right? Let&#8217;s try this:<br />
<code><br />
 def self.boolean_attributes<br />
    self.columns_hash.reject{|k,v| (v.type.to_s != 'boolean') }.keys<br />
  end</p>
<p>  self.boolean_attributes.each do |boolean_attribute|<br />
    define_method "is_#{boolean_attribute}?" do<br />
      !!self.send(boolean_attribute)<br />
    end<br />
  end<br />
</code></p>
<p>There. If there are 12 boolean attributes, you have 12 methods defined dynamically! And if you change the schema, you still have &#8220;is_{new_attribute}?&#8221; in place automatically. </p>
]]></content:encoded>
			<wfw:commentRss>http://jigyasamakkar.com/dynamic-is_-methods-for-boolean-attributes-of-a-model/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails views : Time ago in words for string time</title>
		<link>http://jigyasamakkar.com/ruby-on-rails-views-time-ago-in-words-for-string-time/</link>
		<comments>http://jigyasamakkar.com/ruby-on-rails-views-time-ago-in-words-for-string-time/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 04:54:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[time zone]]></category>
		<category><![CDATA[time_ago_in_words]]></category>

		<guid isPermaLink="false">http://jigyasamakkar.com/?p=204</guid>
		<description><![CDATA[I worked my way around an interesting information tidbit discovery yesterday. The use case seemed pretty simple and direct. I needed to display the &#8220;n hours ago&#8221; text in my view. I used the awesome view helper &#8216;time_ago_in_words&#8217; to do that and it worked, well almost. Here&#8217;s what I&#8217;m talking about: In console, time_string = [...]]]></description>
			<content:encoded><![CDATA[<p>I worked my way around an interesting information tidbit discovery yesterday. The use case seemed pretty simple and direct. I needed to display the &#8220;n hours ago&#8221; text in my view. I used the awesome view helper &#8216;time_ago_in_words&#8217; to do that and it worked, well almost.</p>
<p>Here&#8217;s what I&#8217;m talking about:<br />
In console,</p>
<p><code> time_string = "2010-07-21 11:52:31"<br />
helper.time_ago_in_words(time_string) # => about 5 hours<br />
</code></p>
<p>The catch here is that the &#8220;5 hours&#8221; duration is incorrect. This was hardly 5 minutes ago! So, the problem here was in time zones.<br />
By default, </p>
<p><code>time_string.to_time # => Wed Jul 21 11:52:31 UTC 2010<br />
</code><br />
Notice the time zone offset. It has been set to &#8220;UTC&#8221; by default. But the original time zone of this string time was different. And the tricky part is, it was different for different environments. So how&#8217;d we get past this? Here&#8217;s the entire snippet:<br />
<code><br />
  def custom_time_ago_in_words(time_str)<br />
      time = time_str.to_time + (-Time.zone_offset(Time.now.zone))<br />
      "#{time_ago_in_words(time)} ago"<br />
  end<br />
</code><br />
This essentially adjusts the time according to the server time zone and gives correct output as &#8220;5 minutes ago&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://jigyasamakkar.com/ruby-on-rails-views-time-ago-in-words-for-string-time/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>ActiveRecord Object to Hash assignment in Ruby on Rails</title>
		<link>http://jigyasamakkar.com/activerecord-object-to-hash-assignment-in-ruby-on-rails/</link>
		<comments>http://jigyasamakkar.com/activerecord-object-to-hash-assignment-in-ruby-on-rails/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 10:48:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://jigyasamakkar.com/?p=198</guid>
		<description><![CDATA[I find a frequent scenario in Ruby on Rails code base. A local hash variable is assigned a partial subset of an ActiveRecord object, or worse the variable gets the entire AR object. And may be you don&#8217;t already do it the way I have seen it, but its still worth discussing, being as frequent [...]]]></description>
			<content:encoded><![CDATA[<p>I find a frequent scenario in Ruby on Rails code base. A local hash variable is assigned a partial subset of an ActiveRecord object, or worse the variable gets the entire AR object. And may be you don&#8217;t already do it the way I have seen it, but its still worth discussing, being as frequent a requirement as it is.</p>
<p>1. If we want to assign an entire AR object to a local hash:<br />
A direct assignment is possible with &#8220;attributes&#8221;</p>
<p><code>local_hash = session_user.attributes</code></p>
<p>the &#8216;local_hash&#8217; now has an attribute-value hash of the session_user object, an ActiveRecord object of model User ]</p>
<p>2. If we need the local_hash to have only a subset of the AR object attributes:</p>
<p><code>desired_keys = ['address' , 'zipcode' , 'city' , 'country']<br />
local_array = session_user.attributes.select{|key,value| desired_keys.include?(key) }<br />
local_hash = Hash[*local_array.flatten]</code></p>
<p>the &#8216;local_hash&#8217; now has only the desired attribute values. This can easily be extended by simply adding more keys to &#8216;desired_keys&#8217;.<br />
Instead of what I usually see,</p>
<p><code>local_hash = {<br />
                       'address' => session_user.address,<br />
                       'zipcode' => session_user.zipcode,<br />
                       'city'        => session_user.city,<br />
                       'country'  => session_user.country<br />
                      }</code></p>
<p>What do you think of this snippet? Is there a shorter/smarter way of doing this? Think on!</p>
]]></content:encoded>
			<wfw:commentRss>http://jigyasamakkar.com/activerecord-object-to-hash-assignment-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>YAML Oddity for Ruby arrays</title>
		<link>http://jigyasamakkar.com/yaml-oddity-for-ruby-arrays/</link>
		<comments>http://jigyasamakkar.com/yaml-oddity-for-ruby-arrays/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 07:37:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[YAML]]></category>

		<guid isPermaLink="false">http://jigyasamakkar.com/?p=194</guid>
		<description><![CDATA[I discovered this interesting nugget of oddity today. While normal Ruby arrays are &#8216;comma separated&#8221; and space agnostic ie. >> array = [2,3 ,4, 5] => [2, 3, 4, 5] >> array.size => 4 >> array_spaces = [2 , 3 , 4 , 5] => [2, 3, 4, 5] >> array_spaces.size => 4 In case [...]]]></description>
			<content:encoded><![CDATA[<p>I discovered this interesting nugget of oddity today. While normal Ruby arrays are &#8216;comma separated&#8221; and space agnostic ie.<br />
<code><br />
>> array = [2,3 ,4, 5]<br />
=> [2, 3, 4, 5]<br />
>> array.size<br />
=> 4<br />
>> array_spaces = [2 , 3 , 4 , 5]<br />
=> [2, 3, 4, 5]<br />
>> array_spaces.size<br />
=> 4<br />
</code></p>
<p>In case of YAML, the spaces between array elements makes a difference. A much needed code snippet :</p>
<p>A file &#8216;myfile.yml&#8217;<br />
<code><br />
array: [ 1 , 2 ,3, 4]<br />
array_spaces: [1 , 2 , 3 , 4]<br />
</code><br />
Loading this file in &#8216;irb&#8217;:<br />
<code><br />
>> f =YAML.load_file('myfile.yml')<br />
=> {"array"=>[1, "2 ,3", 4], "array_spaces"=>[1, 2, 3, 4]}<br />
>> f["array"]<br />
=> [1, "2 ,3", 4]<br />
>> f["array"].size<br />
=> 3<br />
>> f["array_spaces"]<br />
=> [1, 2, 3, 4]<br />
>> f["array_spaces"].size<br />
=> 4<br />
</code></p>
<p>Now that&#8217;s not Ruby-ish. But then, as a seasoned co-developer pointed out, YAML should be language agnostic. I still find it a bit odd, though. Hmmm, interesting. Point taken.</p>
]]></content:encoded>
			<wfw:commentRss>http://jigyasamakkar.com/yaml-oddity-for-ruby-arrays/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails Must follow RSS feeds</title>
		<link>http://jigyasamakkar.com/ruby-on-rails-must-follow-rss-feeds/</link>
		<comments>http://jigyasamakkar.com/ruby-on-rails-must-follow-rss-feeds/#comments</comments>
		<pubDate>Fri, 21 May 2010 05:46:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://jigyasamakkar.com/?p=183</guid>
		<description><![CDATA[Ruby on Rails community is fast growing. Too much is happening, and too fast. Its important to keep ourselves abreast of the latest in our community. Following are some RSS feeds I follow religiously [ well, I try]. So configure your favorite Reader and put on your reading caps: Always begin by looking at RoR [...]]]></description>
			<content:encoded><![CDATA[<p>Ruby on Rails community is fast growing. Too much is happening, and too fast. Its important to keep ourselves abreast of the latest in our community. Following are some RSS feeds I follow religiously [ well, I try]. So configure your favorite Reader and put on your reading caps:</p>
<p>Always begin by looking at RoR guides:<br />
<a href="http://guides.rubyonrails.org/">Ruby on Rails guides</a></p>
<p>The BEST Ruby on Rails resource that gives a consolidated set from many relevant RoR resources:<br />
<a href="http://www.drinkrails.com/feeds/posts/default?alt=rss">Drink Rails</a></p>
<p>The renowned railscasts<br />
<a href="http://feeds.feedburner.com/railscasts">Railscasts</a></p>
<p>RoR @SlideShare<br />
<a href="http://www.slideshare.net/rss/tag/ruby">Ruby @SlideShare</a><br />
<a href="http://www.slideshare.net/rss/tag/rails">Rails @SlideShare</a></p>
<p>Awesome RoR screen casts. Short and concise.<br />
<a href="http://feeds.feedburner.com/rubyplus">Ruby Plus</a></p>
<p>Not very frequently updated, but has good content.<br />
<a href="http://feeds.feedburner.com/monkeyonrails">Monkey on Rails</a></p>
<p>Elaborate content on a wide variety of RoR subjects. By Yehuda Katz is a member of the Ruby on Rails core team.<br />
<a href="http://feeds.feedburner.com/KatzGotYourTongue">Katz Got Your Tongue</a></p>
<p>Usually covered by &#8220;drinkrails&#8221;. Good resource.<br />
<a href="http://feeds.feedburner.com/lindsaar-net">Lindsaar Net</a></p>
<p>Updated, concise and good information resource.<br />
<a href="http://www.railsdispatch.com/posts/feed.rss">Rails Dispatch</a></p>
<p>Latest on Rails. Tonnes of new and interesting stuff.<br />
<a href="http://feeds.feedburner.com/RailsInside">Rails Inside</a></p>
<p>Short concise everyday Rails tips.<br />
<a href="http://feeds.feedburner.com/railsquicktips">Rails Quick Tips</a></p>
<p>The latest developments in Rails, all in one place<br />
<a href="http://feeds.feedburner.com/RidingRails">Riding Rails</a></p>
<p>Rails notes. Solutions to every day &#8220;how-tos&#8221;.<br />
<a href="http://feeds.feedburner.com/railsnotes">Rails Notes</a></p>
<p>Get your Ruby right with quick Ruby tips.<br />
<a href="http://feeds.feedburner.com/RubyQuicktips">Ruby Quick Tips</a></p>
<p>Awesome Ruby resource. 5 minutes of Ruby goodness.<br />
<a href="http://feeds.feedburner.com/Ruby5">Ruby5</a></p>
<p>Another amazing Ruby resource. Concise episodes. Really useful.<br />
<a href="http://feeds.feedburner.com/rubypulse_episodes">Ruby Pulse Episodes</a></p>
<p>A good collection.<br />
<a href="http://feeds.feedburner.com/RailsCoach">Rails Coach</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jigyasamakkar.com/ruby-on-rails-must-follow-rss-feeds/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

