<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4462497484400593443</id><updated>2023-11-15T10:56:30.944-06:00</updated><category term="ruby"/><category term="rails tips/tricks"/><category term="yml"/><category term="CMS"/><category term="agile"/><category term="coding practices"/><category term="continuous delivery"/><category term="dropbox"/><category term="firefox"/><category term="git"/><category term="i18n"/><category term="japanese"/><category term="java"/><category term="rails configuration"/><category term="rails http_streaming"/><category term="rails migrations"/><category term="rspec"/><category term="ruby rails active_record validations"/><category term="ruby rails active_resource filter_param"/><category term="ruby rails app_constants"/><category term="thunderbird"/><category term="truecrypt"/><title type='text'>vijay&#39;s technical spot</title><subtitle type='html'>Some random learnings on technologies that I am exposed to on a day-to-day basis.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-2782199363575445349</id><published>2015-06-14T05:53:00.001-05:00</published><updated>2015-06-15T09:45:26.518-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="agile"/><category scheme="http://www.blogger.com/atom/ns#" term="CMS"/><category scheme="http://www.blogger.com/atom/ns#" term="continuous delivery"/><title type='text'>One effective way to use a CMS</title><content type='html'>In most projects involving content managed (for internalization requirements) using CMSes, developers, project managers and content maintainers always seem to be pulling in different directions. This is due to the fact that project managers are concerned with taking &quot;it&quot; to production, developers always go into the &quot;solutioning&quot; mode, whereas content curators (marketing?) are concerned with getting the &quot;right&quot; content in front of the target audience.&lt;br /&gt;
&lt;br /&gt;
Typically, once the developers are done developing the functionality, they also should have extracted out the snippets/placeholders in the web app to some CMS. When this goes out to UAT, it typically also goes out to the [usually outsourced] content curators. Here comes the first dilemma: content (mostly single words or phrases) have meaning in the context of how/where they appear in the UI. Without this knowledge, the content authors/translators are handicapped. So, the way we solved this issue in a couple of the past projects was to hook upto the CMS (SiteCore in these cases) using a web service on the CMS side that exposes content over a HTTP url. Since content is usually requested at a page-level for most websites, grouping content at a page level is useful to avoid performance issues. To further solve performance issues (since we didnt want to tax our CMS, and not have to repeatedly fetch the same [unchanged] content data over the network, we also built in some level of caching on the application tier. This cache would be blasted using a hook on the CMS side whenever a content author published new content.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, for the content authors to view the context of the content, we exposed our UAT site with some special query string parameters on each page, so that the externalized divs would be &quot;flagged&quot; to the user visually when (s)he visits the page using a star image on the top right corner of that div/span. Hovering on the div using the mouse would show the key and its ancestral tree within the CMS where the user could navigate to so as to effect a change. Changing this on the CMS, and publishing, and refreshing the app page would show the new content. Using this method, we were able to decouple the need for developers to be involved in pushing the content changes to the site and the content authors were able to publish and effect changes on their own schedule. Once this process was adopted by all roles, developers could push to production with the site showing the default English content as a fallback for non-english locales, and as the content authors pushed their changes, the website would transform. Of course, the only caveat was that the content authors needed to translate whole pages and then export from their UAT instance into the production instance in one shot. Rinse and repeat FTW!&lt;br /&gt;
&lt;br /&gt;
We also used some techniques to store the snippets at a page-level in an application-level caching mechanism (a poor mans memcached), which was also purged whenever the content author published via the CMS. All this was accomplished using a hook from the CMS calling into a service in our application. </content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/2782199363575445349/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2015/06/one-effective-way-to-use-cms.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/2782199363575445349'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/2782199363575445349'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2015/06/one-effective-way-to-use-cms.html' title='One effective way to use a CMS'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-2258637595213472155</id><published>2015-06-09T05:31:00.001-05:00</published><updated>2015-06-09T05:31:03.529-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="coding practices"/><title type='text'>Coding/Design Developer practices - a brain dump</title><content type='html'>This is not a complete list. Its a growing/living document of the practices that I espouse and try to elucidate to all my team mates on different projects/clients....&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;1) Running tests and adding to suite as new functionality is added&lt;br /&gt;2) Keep build/unit test time as small as possible&lt;br /&gt;3) Commit often (multiple times a day) and commit on a task-basis.&lt;br /&gt;4) Breaking the build is ok - as long as it is fixed or reverted quickly. Do not leave for home on a broken build. The whole team should feel empowered to rollback after giving sufficient time for the committer to rectify the build. If this becomes too long, then anyone from the team can revert the commit.&lt;br /&gt;5) Use the best tools for the best job (eg git)&lt;br /&gt;6) Get enough build agents - developers should not be waiting for build queue.&lt;br /&gt;7) dev machines should be as beefy as possible.&lt;br /&gt;8) Use modular code at solution level (for eg using nuget).&lt;br /&gt;9) communicate early and clearly - both about blockers, current work stream + new knowledge (mostly about tech) that could benefit the team as a whole and instigate thinking in different ways to solve your current domain problems.&lt;br /&gt;10) Use tools (that measure code quality metrics) for the tech stack to track the trend as well as break the build in case of going below agreed-upon threshold&lt;br /&gt;11) Use common settings for VisualStudio/ReSharper/StyleCop/etc - and run all these locally as much as possible. (do not depend on the &#39;Personal build&#39; feature to be the safety net). Any change to a setting by a single developer should also be visible to others (Resharper/StyleCop settings are shareable this way)&lt;br /&gt;12) Do not pick up a card for development until the analysis and UI is fully understood. The same goes for the QA&#39;s understanding and documenting the basic Acceptance Criteria (even before development is started).&lt;br /&gt;13) Do not accept a change in requirements while a card is being played. Work already done is anyways done.&lt;br /&gt;14) Each build output should be for a modular deployable unit.&lt;br /&gt;15) Stateless on server-side is good.&lt;br /&gt;16) Common sql injection scenarios, etc should be safe-guarded against&lt;br /&gt;17) Use language features - dont rewrite code from scratch that is already available as part of the core language&lt;br /&gt;18) Keep up-to-date on language enhancements + new tools to do a better job of old problems&lt;br /&gt;19) Each sprint should achieve a value-add to the deployable product. (In some rare cases, this need not achieve a direct business benefit - it could also be targetting fixing of NFRs or reducing tech debt, etc)&lt;br /&gt;20) Keep tech debt documented as well as in check ie do not let it build up. Constant care is required to maintain a healthy codebase (this goes for team practices as well)&lt;br /&gt;21) (DB Design) Two-phase commit in case of domain usage/necessity&lt;br /&gt;22) Data integrity should never be compromised - ever!&lt;br /&gt;23) Support for multiple versions of API services needs to be kept to a minimum possible.&lt;br /&gt;24) DB and HD administration should be kept up constantly. Dont allow the db to build up tremendously.&lt;br /&gt;25) Review what goes &quot;over the wire&quot; when designing/coming up with a solution for a specific requirement&lt;br /&gt;26) Schedule Pre-IPMs and retros to achieve both team inclusivity as well as to blow off steam.&lt;br /&gt;27) Tech huddles are vital for KT - this can also be across roles (not just devs)&lt;br /&gt;28) Security is a big aspect of programming - and should be on the radar right from the beginning.</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/2258637595213472155/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2015/06/codingdesign-developer-practices-brain.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/2258637595213472155'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/2258637595213472155'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2015/06/codingdesign-developer-practices-brain.html' title='Coding/Design Developer practices - a brain dump'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-2676485993367994084</id><published>2011-11-18T05:13:00.001-06:00</published><updated>2011-11-18T17:54:49.861-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="rails http_streaming"/><title type='text'>Why is HTTP Streaming a joke on Rails 3.1?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I have been trying to convert a Rails 3.1 app to use HTTP Streaming. The interesting fact about this app, and others that I have been working on for the past few years is that most of the models are ActiveResource models - not ActiveRecord. In this context, having the controller logic evaluated lazily takes on more importance - but the phrase &quot;Rails 3.1 supports HTTP Streaming&quot; leaves a lot to be desired.

&lt;br /&gt;
&lt;br /&gt;
I first tried to follow Ryan Bates&#39; excellent &lt;a href=&quot;http://railscasts.com/episodes/266-http-streaming&quot;&gt;rails cast&lt;/a&gt;. The tips are good, and I was able to get streaming working in a basic rails app ie one that uses ARecord quite easily.
The key to streaming is the lazy evaluation of any logic that takes time - namely hitting the database (ARecord) or webservices (AResource). For ARecord, the Rails developers have piggy-backed on ActiveRelation&#39;s proxy (scoped) method for lazy evaluation. This is fine for ARecord. But does not work for AResource. This is the place where Rails breaks down.

&lt;br /&gt;
&lt;br /&gt;
What would have been better is if Rails had implemented a way for ALL such instance variables to be defined inside a lambda or Proc (in the controller) - so that the lambda is defined but not evaluated right then and there. And the second piece of the puzzle would have been for the getter of these instance variables (usually used in the views) to automatically evaluate the block the first time around that they were invoked (should only do the eval once).

&lt;br /&gt;
&lt;br /&gt;
One other thing to note is that any logic (instance variables that get assigned in the controller using the &#39;@&#39; symbol) that depend on the above lazy loaded values/attributes have to also be lazy loaded. This can be done using the method outlined &lt;a href=&quot;http://ilikestuffblog.com/2010/09/23/ruby-on-rails-bedtime-stories/&quot;&gt;here&lt;/a&gt; (this is one of the cleaner methods - and I am not sure whether the author was the first one to do it this way - I found other sites with the same way of tackling the problem).&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/2676485993367994084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/11/why-is-http-streaming-joke-on-rails-31.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/2676485993367994084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/2676485993367994084'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/11/why-is-http-streaming-joke-on-rails-31.html' title='Why is HTTP Streaming a joke on Rails 3.1?'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-5870923806271132267</id><published>2011-10-29T23:22:00.003-05:00</published><updated>2011-10-29T23:22:37.810-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ruby rails active_record validations"/><title type='text'>Active Record Validator</title><content type='html'>As your rails project sees multiple releases, you probably have new migrations that were run on your database. This coupled with Rails&#39; default (IMHO, incorrect) attitude of not enforcing foreign key constraints at the db level might cause your old data to become invalid based on new ActiveRecord validations (unless your incremental migrations have taken this into consideration and massaged your data correctly).

In our project, we had created a home-grown solution called ActiveRecordValidator. This would find all records in each table in your database (it was intelligent enough to handle STI, etc and also had a mechanism where you could specify some tables that you did not want to process - for eg audit tables, etc), and invoke valid? on them. If there were any errors, these were printed out to stderr. Progress was printed to stderr. This proved very useful for us, even in development/test so as to validate that all our reference table data was correct. When run against a snapshot of our production database (we setup a run every week against this snapshot data), it would inform us of data that would become invalid when the next production deploy happened. Our development iteration had an ongoing story card to fix such invalid data after talking to our SMEs.

Since this code was done for a client, I could not open source it, but found something similar: &lt;a href=&quot;https://github.com/vraravam/active_sanity&quot;&gt;active_sanity&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/5870923806271132267/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/10/active-record-validator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/5870923806271132267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/5870923806271132267'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/10/active-record-validator.html' title='Active Record Validator'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-6897145853471720261</id><published>2011-10-29T23:02:00.002-05:00</published><updated>2011-11-18T18:03:49.907-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ruby rails app_constants"/><title type='text'>Application constants and accessing these from within Rails.configure block</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Around 4 years ago, when I was on my first ruby project, we came up with a solution to extract all application constants into a yaml file grouped by the rails environment. This concept was not new - but I did not find any plugin that had this functionality. After some time, I came to know about &lt;a href=&quot;https://github.com/leonardoborges/app_constants&quot;&gt;app_constants&lt;/a&gt; from my colleague, Leornado Borges. I have since used this gem in a couple of projects, but am missing one of the functionalities that our home-grown solution had: Our plugin had a method that could be invoked for any environment (we were calling this as part of our rspec suite for every CI run), that would take the aggregate of all the keys in every environment, and list out those keys that were not present in all the environments. This provided us with a way to quickly determine if a developer had added a key, but had forgotten to add it into the test/cucumber/uat/production environments. This was also invoked during deployment to production - so that if the yml file is being overwritten by your deployment tool, then we can be sure that any missing keys are caught during your deployment window - rather than at runtime by your user! (I think I will fork app_constants and implement this functionality - unless leonardo beats me to it!)

&lt;br /&gt;
&lt;br /&gt;
Note: If you are using this gem to extract your constants, but are using these constants within your environment initialization file, you might get an error. The way around this is to extract those specific lines into config.after_initialize blocks.

&lt;br /&gt;
&lt;br /&gt;
For eg:
&lt;br /&gt;
&lt;pre&gt;    config.after_initialize do
      # Enable serving of images, stylesheets, and JavaScripts from an asset server
      config.action_controller.asset_host = &quot;http://#{AppConstants.ASSET_HOST}&quot;
      config.action_mailer.asset_host = &quot;http://#{AppConstants.ASSET_HOST}&quot;
    end
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/6897145853471720261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/10/application-constants-and-accessing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/6897145853471720261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/6897145853471720261'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/10/application-constants-and-accessing.html' title='Application constants and accessing these from within Rails.configure block'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-7860971058690140852</id><published>2011-10-29T21:22:00.002-05:00</published><updated>2011-11-18T18:05:16.527-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ruby rails active_resource filter_param"/><title type='text'>ActiveResource filter params</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;script src=&quot;https://gist.github.com/1319094.js?file=active_resource_filtered_logger.rb&quot;&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Rails provides a way to filter action controller params from being logged. But if your app is talking to a webservice and passing these sensitive parameters, and you have turned on logged for ActiveResource::Base, then these sensitive params are anyways logged! To overcome this, I wrote this snippet:&lt;br /&gt;
&lt;a href=&quot;https://gist.github.com/1319094.js?file=active_resource_filtered_logger.rb&quot;&gt;https://gist.github.com/1319094.js&lt;/a&gt; &lt;br /&gt;
This can obviously be improved by separating out the params to be filtered between your ActionController::Base params and ActiveResource::Base params - but I leave that up to you...(this works for me)&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/1319094.js?file=active_resource_filtered_logger.rb&quot;&gt;
&lt;br&gt;
&lt;/script&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/1319094.js?file=active_resource_filtered_logger.rb&quot;&gt;
&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/7860971058690140852/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/10/activeresource-filter-params.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/7860971058690140852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/7860971058690140852'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/10/activeresource-filter-params.html' title='ActiveResource filter params'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-2781059103713835137</id><published>2011-09-24T03:04:00.002-05:00</published><updated>2011-09-24T03:04:32.171-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><category scheme="http://www.blogger.com/atom/ns#" term="yml"/><title type='text'>Yaml - Yes? No? Maybe?</title><content type='html'>Another interesting thing I found out this past week: the default yaml ruby library auto-converts keys with yes/true/ etc to the boolean true. I kind of expected that yaml might play around with the values - but I didnt expect that I would find such behavior with keys!

Anyways, the way to fix it is to explicitly make the key a string!</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/2781059103713835137/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/09/yaml-yes-no-maybe.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/2781059103713835137'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/2781059103713835137'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/09/yaml-yes-no-maybe.html' title='Yaml - Yes? No? Maybe?'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-3365618105326109959</id><published>2011-09-24T02:55:00.000-05:00</published><updated>2011-09-24T02:55:36.982-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="i18n"/><category scheme="http://www.blogger.com/atom/ns#" term="japanese"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><category scheme="http://www.blogger.com/atom/ns#" term="yml"/><title type='text'>yaml and japanese - translate.rb</title><content type='html'>I had an interesting problem which grew incrementally a couple of weeks ago - and I wanted to share the experience. The problem statement was simple enough: we needed to internationalize the application that I am working on. Since this seemed simple enough with the rails-i18n gem, I wanted to generate the corresponding yml files from a master one automatically by invoking the google translator service. This seemed simple enough - but there was something I did not take into account. And that was: that the default yaml library does not have the ability to store content in languages like japanese. The way it bypasses this is to convert all such characters into unicode and store it (while writing to the yml file) - but this does not play nice when the same file is read in by rails. Enter the ya2yaml gem. This gem was written (not by me) to solve exactly this problem!
Finally, I could invoke the google translator service and write the yml file directly - and my site now shows up with katakana characters correctly!

To help others with the same problem, here is the &lt;a href=&quot;https://gist.github.com/1126964&quot;&gt;code&lt;/a&gt;.
</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/3365618105326109959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/09/yaml-and-japanese-translaterb.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/3365618105326109959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/3365618105326109959'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/09/yaml-and-japanese-translaterb.html' title='yaml and japanese - translate.rb'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-6015168597702946998</id><published>2011-03-22T19:25:00.000-05:00</published><updated>2011-03-22T19:25:17.746-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>junitRunner</title><content type='html'>I have almost given up on working on Java for the past 3+ years, but I am currently assigned to a project that is heavily into Java. When I landed here, I was pleasantly surprised to see most of the devs using &lt;a href=&quot;http://eclipse.org/&quot;&gt;Eclipse&lt;/a&gt;. The daily workflow involved running a lot of junit tests, and when I was pairing with a dev, I noticed that he ran the tests using the mouse (all tests in a suite), and then reran only a specific failed test - using his mouse. This was exactly the usecase for the &lt;a href=&quot;http://sourceforge.net/projects/junitrunner/&quot;&gt;junitrunner&lt;/a&gt; eclipse plugin!</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/6015168597702946998/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/junitrunner.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/6015168597702946998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/6015168597702946998'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/junitrunner.html' title='junitRunner'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-969867568751512793</id><published>2011-03-18T22:49:00.000-05:00</published><updated>2011-11-19T04:59:44.166-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="rspec"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>Stubbing constants for tests</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Yesterday, I read a blog post about &lt;a href=&quot;http://techie.lucaspr.im/stubbing-class-constants-when-testing/&quot;&gt;stubbing class constants for testing&lt;/a&gt;. I think using the before(:all) and after(:all) hooks are not the best way to achieve this. The reasons being that:&lt;br /&gt;
1) This happens for all test methods in that spec file - and is not limited to the [typically] few test methods that &lt;i&gt;do&lt;/i&gt; need overridden values.&lt;br /&gt;
2) Ruby has an elegant mechanism with closures and &#39;yield&#39;, which is not being used.&lt;br /&gt;
&lt;br /&gt;
Instead of the method suggested above, IMHO, this is better:&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/877198.js?file=gistfile1.rb&quot;&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
The above code block ensures that as soon as the block returns, the constants are reset to the old values thus making each test clean up after itself.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/969867568751512793/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/stubbing-constants-for-tests.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/969867568751512793'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/969867568751512793'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/stubbing-constants-for-tests.html' title='Stubbing constants for tests'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-4923519758785539503</id><published>2011-03-17T12:23:00.001-05:00</published><updated>2014-02-25T00:42:58.028-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="git"/><title type='text'>Keep your local git checkout clean</title><content type='html'>In my previous project, active development always happened in trunk except for certain scenarios: spikes, fixing bugs on production release branches, completing some unfinished work on the next production release branch, etc. This caused a lot of our dev pairing machines to have multiple branches. And since we used to rotate pairs very often (every morning), whenever I went to pair on a different machine, I would first run this script:&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/874724.js?file=gistfile1.rb&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
The reason was very simple. When I am working on master, and the machine had multiple other branches (some of them having local changes, while others not), each time I did a push to the remote origin, it would complain (since git tries to push all local branches that track remotes, by default). Of course, we could have written our commit [rake] task in such a way that it deciphered the current branch and only pushed that. But, IMHO, its better to have a clean workspace rather than finding ways to bypass it. I know others who have a different opinion - the most common one being git is a DVCS and that&#39;s how it is supposed to work. That may be the case - everyone is entitled to their opinions. Mine is just that my workspace should be clean.&lt;br /&gt;
&lt;br /&gt;
The above script will go through all the local branches, and pull from their respective remotes. If there is no merge conflict (by parsing the status message), then it would revert back to the master branch and delete the other local branch. This step is repeated for each locally existing branch.&lt;br /&gt;
&lt;br /&gt;
This script and some more that I used to loop through and maintain multiple git repositories are shared through my &lt;a href=&quot;https://github.com/vraravam/git_scripts&quot;&gt;github account&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/4923519758785539503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/keep-your-local-git-checkout-clean.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/4923519758785539503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/4923519758785539503'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/keep-your-local-git-checkout-clean.html' title='Keep your local git checkout clean'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-7595220023247661754</id><published>2011-03-16T23:33:00.000-05:00</published><updated>2011-03-16T23:33:18.497-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="rails tips/tricks"/><title type='text'>Destroy does not actually mean destroy!</title><content type='html'>When I started learning Ruby and Rails, I was fascinated with the rails scaffold generated code. There I was typing away to glory to come up with a webpage on a Java stack barely managing to keep it following a pattern, and here was a simple command line script which when invoked with the correct parameters, would generate the same for me in Ruby - wow!&lt;br /&gt;
&lt;br /&gt;
And then I learned the first step - dont trust the generated code implicitly. Case in point: we had a [business/domain] scenario where the destroy action on an ActiveRecord would need to verify that some condition was satisfied, and if these conditions were not met, the destroy action would raise an error. The scenario in our case was that the entity was in use in some other relationships, and until those were deleted first, this entity could not be destroyed.&lt;br /&gt;
&lt;br /&gt;
For the case of the entity creation, Rails provides a convenient callback mechanism called validations. The same is the case for updates. But for destroys, Rails assumes that all is well. This is carried on into the code generated for the controllers specifically for the destroy action. It just returns a 200 status code. But, as evidenced in our case, that is not always the case, and we had to manually edit all such scaffold-generated code to &quot;fix&quot; the issue.</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/7595220023247661754/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/destroy-does-not-actually-mean-destroy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/7595220023247661754'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/7595220023247661754'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/destroy-does-not-actually-mean-destroy.html' title='Destroy does not actually mean destroy!'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-496332330795886293</id><published>2011-03-16T23:13:00.003-05:00</published><updated>2014-02-25T00:43:49.559-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="firefox"/><category scheme="http://www.blogger.com/atom/ns#" term="thunderbird"/><title type='text'>Backing up Firefox and Thunderbird profiles</title><content type='html'>I have been using Firefox and Thunderbird for the past 10 years or so - since the time when hard drive space was a precious commodity. As I started using more than one machine (or when I completely trashed my OS and had to reinstall it from scratch), I came across a need to copy and maintain these profiles. Since I wanted them to be in some &quot;known&quot; location, and since both these excellent mozilla products provide a way to edit an ini file and thus &quot;move&quot; the profile folders, I have been doing that as well for the past several years. (For more information on where to find your profile directory for your OS, and what to change, please look &lt;a href=&quot;http://kb.mozillazine.org/Profiles.ini_file&quot;&gt;here&lt;/a&gt;.)&lt;br /&gt;
&lt;br /&gt;
I ran across an initial version of this script &lt;a href=&quot;http://ubuntuforums.org/showthread.php?t=1088094&amp;amp;page=4&quot;&gt;here&lt;/a&gt;&lt;br /&gt;
As I started experimenting with bash scripts, I enhanced the above script (that would check if the program/application was running currently, and if not, it would do some common house-cleaning within these profile folders), with some new functionality, like delete some cache folders, etc. &lt;b&gt;This cleanup should never be run when the application is in use - so be warned.&lt;/b&gt; Once the cleaning was done, I also added a cmd-line switch that would go ahead and create a tgz file for backups.&lt;br /&gt;
&lt;br /&gt;
In case anyone is interested, here is the &lt;a href=&quot;https://gist.github.com/vraravam/9203581#file-backup_moz-sh&quot;&gt;script&lt;/a&gt;&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/873815.js?file=gistfile1.eclass&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
This script has been written in bash, and so can be run on windows if you use &lt;a href=&quot;http://www.cygwin.com/&quot;&gt;cygwin&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
You can of course take the script and modify it as you wish. Just be warned (again) that if you do edit it, dont remove the check for skipping the house-cleaning if the application is running. Also, if you end up making any changes, I would appreciate it if you could send me the changes to be incorporated into my copy.</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/496332330795886293/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/backing-up-firefox-and-thunderbird.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/496332330795886293'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/496332330795886293'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/backing-up-firefox-and-thunderbird.html' title='Backing up Firefox and Thunderbird profiles'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-2214332039165783630</id><published>2011-03-16T22:53:00.000-05:00</published><updated>2014-02-25T00:44:35.171-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dropbox"/><category scheme="http://www.blogger.com/atom/ns#" term="truecrypt"/><title type='text'>Git &gt; TrueCrypt &gt; Dropbox: A truly geeky way to backup your home folder across machines and OSes</title><content type='html'>I was searching for ways to backup and sync up my profiles across different machines and across different *nix based OSes that I use (Mac OSX and Ubuntu). The stuff I wanted to sync was stuff like my .zshrc, .vimrc, .irbrc, .ssh, etc. At the same time, there were my firefox and thunderbird profiles that needed to be synced up as well (disregarding the fact that I use some add-ons for these which are OS-specific). Since some of these folders also contained sensitive information, any storage/sync mechanism that I arrived at would need to hold the data in an encrypted fashion. Lastly, I thought it would be good to have a historical backup of these same files/folders.&lt;br /&gt;
&lt;br /&gt;
When I was in India on an assignment for my employer (&lt;a href=&quot;http://www.thoughtworks.com/&quot;&gt;Thoughtworks&lt;/a&gt;), I had some time during the evenings to play around with these requirements and came up with a geeky solution. I would create a git repository (most of the stuff I was storing were ASCII files, not binaries). This was important since git does not scale well for binary files. Next this git repository would go into a &lt;a href=&quot;http://www.truecrypt.org/&quot;&gt;TrueCrypt&lt;/a&gt; container which was configured with sufficient space. Finally, the whole TrueCrypt container [file] would go into my &lt;a href=&quot;http://www.dropbox.com/&quot;&gt;DropBox&lt;/a&gt; account. Done! This would solve all my problems (at least I thought so at that time, but...)&lt;br /&gt;
&lt;br /&gt;
There are some obvious limitations of this approach:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The TrueCrypt container once created, cannot be dynamically made to expand&lt;/li&gt;
&lt;li&gt;Even if the TC file were recreated with a higher storage capacity, it would still need to adhere to the size of my dropbox account (they currently give 2GB free for the basic/free account)&lt;/li&gt;
&lt;li&gt;Syncing a 1.5GB file across three machines - all of them wireless - was seriously overloading my home DSL setup!&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Enter &lt;a href=&quot;http://sparkleshare.org/&quot;&gt;SparkleShare&lt;/a&gt; - the syncing software where you can store the data not on the cloud, but on your own drives! This was featured on one of the ubuntu blogs a few days ago - and it uses the same pattern for storing the data: your data/files/folders are actually encrypted (in lieu of my TrueCrypt step) and stored inside a git repo on whatever network storage device you configure! Yay!&lt;br /&gt;
The only hiccup right now is that their software is still in beta for both Mac and Linux - but maybe I will try it out sometime soon and post my review/experiences.</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/2214332039165783630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/git-truecrypt-dropbox-truly-geeky-way.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/2214332039165783630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/2214332039165783630'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/git-truecrypt-dropbox-truly-geeky-way.html' title='Git &gt; TrueCrypt &gt; Dropbox: A truly geeky way to backup your home folder across machines and OSes'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-1174103108699367630</id><published>2011-03-07T06:29:00.000-06:00</published><updated>2011-03-07T06:29:15.178-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="rails configuration"/><title type='text'>externalizing configurations across different rails environments</title><content type='html'>In all the rails projects that I have worked on during the past 3 years, I have come across a pattern where some configurations need to be externalized. These configurations could include sensitive information (authentication passwords for a 3rd party system), application runtime information (like number of items to show in a paginated list), environment-specific information (like development vs uat vs production). To accomplish this, it is very trivial to write a Registry module that would load up a few yaml files into a hash in memory. Each file is loaded and if the same key exists from a previous file, the new value would super-impose the one in memory - so that ultimately, there is one &quot;master&quot; copy that the application runtime would use. (This concept has also been prevalent for more than a decade in the Java world - I used it in 2000). As I said before, this is pretty trivial to write. While browsing in github, I came across this project: https://github.com/lukeredpath/simpleconfig - which has almost exactly the same features, in a cleaner way! Now onto forking that project and converting it into a gem...</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/1174103108699367630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/externalizing-configurations-across.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/1174103108699367630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/1174103108699367630'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/03/externalizing-configurations-across.html' title='externalizing configurations across different rails environments'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-196176710004576300</id><published>2011-02-28T22:55:00.000-06:00</published><updated>2011-02-28T23:31:00.081-06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="rails migrations"/><title type='text'>Consolidating rails migrations</title><content type='html'>With the meteoric rise in adoption of rails as a framework to develop business applications, we as developers need to also remember that these same codebases need some amount of love/house-cleaning from time to time. One of the areas that I want to highlight is database migrations.&lt;br /&gt;
&lt;br /&gt;
As new releases of the app is deployed to production, and development of new features (needing new migrations) continues, it would be a good practice to consolidate previously run migrations into a single file. The idea is simple:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Use the [default] VERSION environment variable to specify the migration till which you want to consolidate&lt;/li&gt;
&lt;li&gt;Drop, create and migrate the database till this version&lt;/li&gt;
&lt;li&gt;Copy the resulting schema.rb file into the migration (replacing the old content of the &#39;self.up&#39; method) in migration with that same version number&lt;/li&gt;
&lt;li&gt;Typically you will never go below this migration, so raise an &#39;ActiveRecord::IrreversibleMigration&#39; exception in the corresponding &#39;self.down&#39; method&lt;/li&gt;
&lt;li&gt;Delete older migrations (prior to the specified one)&lt;/li&gt;
&lt;li&gt;Commit into your scm&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
At my previous client, we implemented a rake task to accomplish these steps in an automated fashion. Once a release went to production and after a couple of days of &quot;settling down&quot;, this rake task was run with the version of the [production] db.&lt;br /&gt;
&lt;br /&gt;
The advantage of doing this is:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Typically, as design evolves, you might rename/drop columns, drop tables, add seed data, etc which are all collapsed into a single step&lt;/li&gt;
&lt;li&gt;The number of files that need to be evaluated and run (each time the db is recreated, typically, when running tests) is smaller, and thus taking [fractionally] less amount of time&lt;/li&gt;
&lt;li&gt;Forces you, the developer, to maintain seed data outside migrations&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/196176710004576300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/02/consolidating-rails-migrations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/196176710004576300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/196176710004576300'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/02/consolidating-rails-migrations.html' title='Consolidating rails migrations'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4462497484400593443.post-2895857379955600506</id><published>2011-02-27T02:03:00.003-06:00</published><updated>2011-03-16T23:24:54.476-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="rails tips/tricks"/><title type='text'>Rails tricks: Require correctly</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;On one of my previous projects, we noticed some strange (to us) behavior: any extra spec behavior (extra methods, config.before(:all), etc) was being loaded/defined more than once while running the whole suite of tests, but when we tried to run a single spec class (ie all tests defined within one file), this behavior was not evident. Digging further, we found that this was caused by requiring the spec_helper. As each spec file is being &quot;processed&quot;, the require statement at the top of the file got triggered, and when a new file (at a different relative directory) was encountered, the spec_helper line would usually trigger this scenario. For eg:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
spec/a_spec.rb: require File.dirname(__FILE__) + &#39;/spec_helper&#39;&lt;br /&gt;
spec/models/b_spec.rb: require File.dirname(__FILE__) + &#39;/../spec_helper&#39;&lt;br /&gt;
spec/lib/level1/c.rb: require File.dirname(__FILE__) + &#39;/../../spec_helper&#39;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
To solve this, we resorted to using the fully expanded path to the spec_helper - since this would resolve to the same file each time. In this case, the above files were changed so:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
spec/a_spec.rb: require File.expand_path(&#39;spec_helper&#39;, File.dirname(__FILE__))&lt;br /&gt;
spec/models/b_spec.rb: require File.expand_path(&#39;../spec_helper&#39;, File.dirname(__FILE__))&lt;br /&gt;
spec/lib/level1/c.rb: require File.expand_path(&#39;../../spec_helper&#39;, File.dirname(__FILE__))&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
UPDATE: My good friend and colleague &lt;a href=&quot;http://blog.brianguthrie.com/&quot;&gt;Brian Guthrie&lt;/a&gt; corrected me saying that this situation can be avoided if the load path is set correctly (to include the spec folder) through the rake task before actually invoking rspec. That sounds reasonable, but I have yet to try it out - and unfortunately, I have moved on from the project where this was sorely needed.</content><link rel='replies' type='application/atom+xml' href='http://vijaysspot.blogspot.com/feeds/2895857379955600506/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vijaysspot.blogspot.com/2011/02/rails-tricks-require-correctly.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/2895857379955600506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4462497484400593443/posts/default/2895857379955600506'/><link rel='alternate' type='text/html' href='http://vijaysspot.blogspot.com/2011/02/rails-tricks-require-correctly.html' title='Rails tricks: Require correctly'/><author><name>Vijay Aravamudhan</name><uri>http://www.blogger.com/profile/05637309012758011714</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>