Category Archives: Ruby on Rails

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…

Read More

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…

Read More

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….

Read More

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…

Read More

’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…

Read More