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 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 »
Posted by firstruby on May 9, 2010
We can restrict the routes listing to particular CONTROLLER by passing CONTROLLER variable as,
rake routes CONTROLLER=profiles
Above command will display routes of profiles controller.
Posted in Useful Links | Tagged: rails, rake, RoR, routes | Leave a Comment »
Posted by firstruby on November 29, 2009
For users list, I wanted to have AJAX pagination.
For Ruby on Rails version 2.3.x,
1) Install will_paginate gem “config.gem “will_paginate”” or include will_paginate plugin in vendor/plugins.
2) Create helper file at /app/helpers/remote_link_renderer.rb with following content,
Here I’m attaching remote_link_renderer.rb.pdf file , copy contents from remote_link_renderer.rb.pdf and create file remote_link_renderer.rb
3) In controller action, write as following,
render :update do |page|
page.replace_html "users_list", :partial => "users", : object => @users
4) On “_users_list.html.erb” view page, write as,
= will_paginate @users, :renderer => 'RemoteLinkRenderer'
Posted in Useful Links | Tagged: ajax, pagination, rails, RoR, ruby on rails | Leave a Comment »
Posted by firstruby on November 16, 2008
To install ri and rdoc of any gem,
gem install gemname
This command installs ri and rdoc with installation of gem.
To skip the installation of ri and rdoc of gem,
gem install gemname –no-ri –no-rdoc
This command will skip the installation of ri and rdoc when installing gem.
Posted in firstruby, Forum, Useful Links | Tagged: gem, rails, rdoc, ri | Leave a Comment »
Posted by firstruby on November 3, 2008
We can pass the multiple parameters with remote_function or link_to_remote…
<%= link_to_remote "View Data",
:url => :action => "list",
:with => " 'name=' +$('div-id-of-name-text-box').value + '&city=' +$('div-id-of-city-text-box').value + '&country=' +$('div-id-of-country-text-box').value " %>
<%= remote_function(:url => :action => "list",
:with => " 'name=' +$('div-id-of-name-text-box').value + '&city=' +$('div-id-of-city-text-box').value + '&country=' +$('div-id-of-country-text-box').value " ) %>
Posted in Useful Links | Tagged: link_to_remote, rails, remote_function | 3 Comments »