Posted by firstruby on November 13, 2011
While installaing json gem in Ruby on Rails 3.0 or 3.1, I was getting following error,
$ gem install json -v=1.4.6 –platform=ruby –no-ri –no-rdoc
Fetching: json-1.4.6.gem (100%)
ERROR: Error installing json:
The ‘json’ native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from ‘http://rubyinstaller.org/downloads’ and follow the instructions
To fix this problem, need to install Development Kit (DevKit – Its a toolkit that makes it easy to build and use native C/C++ extensions for Ruby on Windows) as follows,
1) Download DevKit file from http://rubyinstaller.org/downloads (DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe)
2) Extract DevKit to path C:\Ruby192\DevKit
3) Goto DevKit installation directory,
4) Run following command,
ruby dk.rb init
It will generate the config.yml file. This config file should include installed Ruby path, like “C:\Ruby192”
5) Run following command,
ruby dk.rb review
It is useful to review the list of Rubies to be enhanced to use the DevKit and verify the changes you made to it are correct.
6) Run following command,
ruby dk.rb install
It is useful to enhance your installed Rubies and makes it easy to build and use native C/C++ extensions such as json.
Reference : https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
Posted in Useful Links | Tagged: DevKit, gem, json, rails 3.0.x, windows | 25 Comments »
Posted by firstruby on October 2, 2011
Following is the way to pass command line argument to Rake task,
rake app:test argument_name=’Hello World’
And read command line argument in following rake task,
namespace :app do
task :test => :environment do |t|
Posted in Useful Links | Tagged: rake | Leave a Comment »
Posted by firstruby on September 1, 2011
Posted in Useful Links | Tagged: deployment, heroku, rails 3.1, ruby | Enter your password to view comments.
Posted by firstruby on August 25, 2011
With Ruby 1.9.2 and Rails 3.0.10,
If you are facing following problem while doing “rake db:migrate”,
Mysql::Error: query: not connected: SHOW TABLES
then you may need to download ‘libmySQL’ from http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll and paste that in C:\Ruby192\bin folder.
Posted in Useful Links | Tagged: migrate, migration, mysql, rails, ruby | Leave a Comment »
Posted by firstruby on July 17, 2011
If you got following error,
OpenSSL::Cipher::CipherError (Illegal key size)
it means you need to install ‘Java Jurisdiction policy files’. These files can be downloaded from http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html and copy ‘local_policy.jar’, ‘US_export_policy.jar’ and replaced at ‘C:\Program Files\Java\jdk1.6.0\jre\lib\security’.
Posted in Useful Links | Tagged: jar, java, jruby, openssl, rails | 1 Comment »
Posted by firstruby on June 23, 2011
You may want to add HTTP authentication to your Ruby on Rails site, add following to your application controller file,
authenticate_or_request_with_http_basic do |username, password|
username == "test" && password == "test"
After adding these lines, application will ask for username and password.
Posted in Useful Links | Tagged: authentication, HTTP authentication, rails, ruby | Leave a Comment »
Posted by firstruby on May 29, 2011
Language fallback mechanism in Ruby on Rails is very useful. It is useful in 2 ways,
1) File missing : If particular locale file say German locale ‘de’ is set from browser, then Rails application will look for de.yml file in /config/locales folder, and if de.yml is missing, then by default language fallback mechanism will load en.yml file as default.
2) Entry missing: If German locale ‘de’ is set from browser, then Rails application will look for de.yml file in /config/locales folder. In case, particular entry is missing in de.yml file, then conversion for the same language will be loaded from en.yml file.
To achieve this, just need to install latest I18n gem and need to create file /config/initializers/i18n.rb file with following,
Reference URL : http://stackoverflow.com/questions/2324398/fall-back-to-default-language-if-translation-missing
Posted in Useful Links | Tagged: i18n, internationalization, localization, rails | Leave a Comment »
Posted by firstruby on March 17, 2011
Posted in Useful Links | Tagged: deployment, heroku, rails 3.0.x, ruby | Enter your password to view comments.
Posted by firstruby on February 20, 2011
Following is the Regular expression which accepts numbers, plus (+), miuns (-) symols and skips alphabets,
This RegEx can be useful for Phone number validation.
Posted in Useful Links | Tagged: rails, RegEx | Leave a Comment »
Posted by firstruby on February 2, 2011
If you want to call helper method from ActionMailer view in Ruby on Rails (RoR) application, you need to include helper (module) in Mailer file as,
If Helper module name is “UserHelper”, then need to write following in Mailer file,
After this, you will be able to access all the methods written in UserHelper in ActionMailer views.
Hope this is helpful.
Posted in Useful Links | Tagged: actionmailer, helper, module, rails | Leave a Comment »