Acts_as_solr: Starting solr server on windows
I was using acts_as_searchable for one of my project, which uses Hyperestraier in background. Yesterday I decided to use acts_as_solr which uses solr(based on Lucene Java search library). I did all written in its Manual/Readme, but when I issued
to start the solr server, it threw a heart breaking “Bad file descriptor” error, although acts_as_solr was working fine on one of my colleague’s linux machine.
I started digging around this and found that there is an issue in rake task that starts the solr server. Actually the problem was this rake task uses ‘fork’ which is not available on windows, also it only handles ‘ECONNREFUSED’ exception which is actually “Connection Refused” error raised by ruby on linux. But in windown it throws ‘EBADF’ which is “Bad file descriptor” error raised by ruby on windows.
So below is the hack for that:
Just add this to vendor/plugins/acts_as_solr/lib/taks/solr.rake, and start solr server on windows by issuing
Customizing CruiseControl build for RSpec
Yesterday I posted about CruiseControl for Rails projects. It was working fine with all my rails projects using traditional test cases, But today I faced a problem with a project using RSpec. Actually, By default CruiseControl follows the following step to build:
- rake db:test:purge
- rake db:migrate
- rake test
This default was not working with my last project As I was using RSpec for my project. I found that we can overwrite default way of building by creating a rake task named cruise in our project. Means by building CruiseControl will run your custom rake task only, so you have to take care of all other things i.e. migrate etc.
Hence I created following rake task in RAILS_ROOT/lib/tasks/custom_cc.rake
and it worked for my rails project using RSpec.
CruiseControl.rb: A Continuous integration tool for your rails projects.
We at vinsol recently started using CruiseControl for our rails project. CruiseControl is a continuous integration tool. Which keeps an eye on you code repository and runs all test cases (or the command you specify) whenever new version of code is found, it also sends a mail to all members specified when testcases fails with details. I found this tool very helpful and customizable. If you don’t use CruiseControl , I suggest you to give it a try.
Careful while using Exception Notifier Plugin
Exception Notifier Plugin can make you crazy as it made me yesterday.
Let me explain, I was using this plugin for one of my project and our server got a DOS attack. We were requested some URLs that doesn’t exists, like http://somedomain.com/game.rar etc… . I had registered my gmail account to get notifiers. And due to this attack I was sent around 7631*61 mails in 10 hrs. This made me crazy, because I was unable to receive any other email as (may be) my queue was busy with receiving notifier mails. Then gmail started bouncing back those mails saying “The Gmail user you are trying to contact is receiving mail at a rate that prevents additional messages from being delivered. Please resend your message at a later
time”. And then it became a loop, Gmail-My Server-Gmail.
I found 303552 mails in postfix queue of my server. That were ready to send to gmail. Now my first priority was to clean that postfix queue, so I did it by issuing “sudo postsuper -d ALL”. I hope to receive mails ASAP, It is now more than 48 hrs i received any genuine mail.
So I request you to be careful while using this plugin ![]()
Note: Since my gmail account not receiving mails, so please sent it to akhil at vinsol dot com
Get svn commit notification right into your inbox by using svn hook post-commit
If you wish you can get notification right into your inbox when a team member commits the code. This mail will contain list of files added/deleted along with the svn diff of files that are modified. This needs some extra efforts to setup, but once it is setup it is very helpful.
This can be done by using svn hooks. Yes, svn has inbuilt hook functionality like pre-commit, post-commit, post-lock, post-unlock, pre-lock, pre-unlock, start-commit. We’ll use post-commit hook to get notifications.
First of all get a perl script from here http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/commit-email.pl.in and copy it to hooks directory inside your repository directory, lets say /var/www/repos/repository_name/hooks.
Make sure to rename it as commit-email.pl, ofcourse you need perl installed on your server. Now cd to hooks directory inside you repository directory. Rename post-commit.tmpl to post-commit, and chmod 755 to post-commit and commit-email.pl . Now open post-commit in you favorite editor, and put “/usr/bin/perl /var/www/repos/commit-email.pl –from svn-notify@example.com -s ‘SVN commit notification’ ‘$REPOS’ ‘$REV’ user_whom_to_notify@example.com, another_user_to_notify@example.com” at the bottom of that file. Now open commit-email.pl and make changes in configuration section according to your requirement and server, specially svnlook path.
Congrats!, You are done
.
Now your server will send email notification to user_whom_to_notify@example.com, another_user_to_notify@example.com whenever someone commits.
**For security reasons, the Subversion repository executes hook scripts with an empty environment that is, no environment variables are set at all, not even $PATH or %PATH%. Because of this, a lot of administrators are baffled when their hook script runs fine by hand,but doesn’t work when run by Subversion. Be sure to explicitly set environment variables in your hook and/or use absolute paths to programs.
It worked for me, Please let me know if it works for you too.
Is SVN really atomic?
I am just wondering if svn is really atomic. Actually some days ago I freezed rails and tried to commit but due to some network problem the commit process failed. And then I found some of those files under version control, which should not be there if snv is atomic. I tried many times to commit after svn delete those files, but stuck with the same problem. May be I misunderstood some thing about svn. Did somebody also faced same problem?
Travel Mate: New Widget For Opera
Going out for vacation??? Plan your trip using Travel Mate. ![]()
Actually some days ago there was a call from Opera to all developers to make widget for travelers, and to promote developers they announced some prizes like Windows based mobile Phone. Me and my colleague Aditya decided to try our luck, but unfortunately I could not submit it before the deadline but he could.
Aditya made a nice widget that has features like Road Map, Weather Report, Local Photos, Flight Booking, Currency Converter and World clock with DST support. He is using javascript library(prototype.js) and YUI (Yahoo User Interface) for making the widget user friendly and code efficient. Google Maps API, Yahoo Travel API and many other APIs are being used in this widget. And no scraping is done that makes Travel Mate a highly stable solution.
I hope, he get this phone so I get new battery for my phone ![]()
If you use Opera, tryout Travel Mate Widget and give your valuable comment.
Get Travel Mate from here.
nil.id problem: Wondering why the id 4 is getting saved in Table instead of actual id?
Today I figured out the problem which is troubling me from 3-4 months, I am referring here it as “nil.id problem” .
Actually the situation was: User belongs_to :network, and Network has_many :users (simple association)
so I wanted to save network id in users table as network_id an attribute. There were all the necessary validations in User model(like validate_presence_of :network_id etc..). But some times(once in thousands) it saves ‘4′ as a network_id, which was a big problem because there was no network with id ‘4′, so where this ‘4′ came from, any idea???
Answer: I faced this problem today again with some other model. And I started digging around this and finally got the root of this bug. Actually I was saving user object like:
Now, what if group.network return nil, will it throw an exception? No, In that case user.network_id will be 4, because then user.network_id is actually saving nil.id and nil.id is always ‘4′. And this was the root of that error. But nil.id is deprecated now.
Stuck with capistrano
I was deploying my latest code to live site today using Capistrano, and suddenly I stuck. When I tried to deploy the code, it checked out the latest version on the server and while executing after_symlink task it rolled back. I was surprised because the deploy script was working fine earlier and I haven’t made any change in deploy.rb or deploy procedure. I tried many times but not succeed, and then I found the root of problem.
The problem was that I mistakenly created a file in releases directory and Capistrano uses ln -x1 command to create symbolic link to current release. And Capistrano links last output of ‘ln -x1′ as ‘current’, so in this case ‘current’ was linking to a file. This was doing all the mess, as ‘current’ was pointing to a file instead of latest release directory. I deleted that file from releases and then it worked fine…
wanna add keyboard shortcuts to your web application?
Today I was looking for some javascript to add keyboard shortcuts to my project. And after little search on google I came across a very cool and lightweight javascript library shortcuts.js .
This library allows you to make keyboard shortcuts on a fly.
Example:
Please visit this site to know more about this javascript library.
Welcome to WebOnRails
Thank you for taking the time to visit my blog! Take a second to peek around and check out some of my previous posts. Of course, I would love to find out what you think as well, so make sure to comment. See you around!
One more thing, if my posts helps you then kindly Recommend me on Working With Rails



Recent Comments