Category Archives: Ruby on Rails
HTTP basic authentication using email address
In my previous article, I have written about HTTP basic authentication in rails using a plain user access YML. Last few days ago, I have modified the logic to log-in using email address and password. So that anyone don’t need to remember another new password. Hope it might help you… Written a news private method…
HTTP basic authentication in rails to protect staging server
Sometimes, you may need to protect your staging server from outside world. It can be done easily by using http basic authentication in rails3. I did following things to use HTTP basic authentication to protect my staging server: YML file with username and password pair: devuser: devpasstestuser: testuserpass Loaded YML data from application initializer: HTTP_AUTH_USERS…
Rails application deployment using shell script
I have used following shell script to deploy one of my Ruby on Rails applications: DATES=`date +%Y%m%d%H%I%S`service apache2 stop &&mysqldump -u[user] -p[pass] [yourdbname] > “your backup directory”[yourdbname]_${DATES}.sqlgit pull &&bundle install –path [your bundle path] &&bundle exec rake db:migrate RAILS_ENV=production &&mv [your application’s production log file] [your application’s production log backup path]/production_${DATES}.log &&touch [your application’s production…
Using helper method from action mailer views
Action Mailer of Ruby on Rails(RoR) allows you to send emails from application using a mailer model and views. Sometimes you may need to use any helper method though it does not allow by default. In that case you have to include helper(module) in the Mailer class. Say, you may need to use method(s) from…
Ruby interpreter has stopped working
From last couple of days, I was facing a problem with my ruby interpreter. It was crashing continuously after few page requests and getting message: Ruby interpreter (CUI) 1.9.2p180 [i386-mingw32] has stopped working I have tried to find out the reason and frequency to stopped but couldn’t find the actual reason. After googling got a…
Install mysql2 gem on Windows 7
Last couple of days ago, I was stuck to install mysql2 gem on windows7 for rails3 and tried lots of instructions by googling. Unfortunately, those were not worked for me. Finally, I have specified a older version of mysql2 during installation which worked for me. Following are the steps which i did: Install Mysql 5.5…
Unpacked gem has no specification file
I started working on a new rails project and in every time from command line operation getting this type of irritating message: config.gem: Unpacked gem ….. in vendor/gems has no specification file. Run ‘rake gems:refresh_specs’ to fix this. I run rake gems:refresh_specs but the problem isn’t fixed. Moreover, tried by creating specification file as well….
How to disable logging in Rails application
It’s not a good practice to do though depends on your needs. It can be done by two ways, one is to disable for whole application and another is to disable for specific environments. You’re probably looking for some or all of the following settings: config.loggerconfig.active_record.loggerconfig.action_controller.loggerconfig.action_view.loggerconfig.action_mailer.loggerconfig.active_resource.logger If you set any of them to nil like…
’rails’ is not recognized as an internal or external command, operable program or batch file
You might experience the problem due to the following reasons: You haven’t installed Rails Rails path cannot be found Installed Rails using a ‘special’ installer To resolve the issue, uninstall rails installation from your PC and try a normal installation through command prompt by using following command: gem install rails –include-dependencies Note: Be sure, you…
How to use mutliple ruby version on windows
I have found a nice ruby version manager for windows named pik. It’s pretty easy to install and manage multiple ruby versions. First install the pik gem: gem install pik After installing the pik, you have to use pik_install script to install the pik executable. You must install pik in a different directory other than…