Tuesday, October 20, 2009

Ralis 2.2 with mysql Resolved errors

When you work in Rails 2.2 , with mysql you may get following error after installing mysql driver and trying to run the project.

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install
the mysql gem and try again: gem install mysql.
rake aborted!
126: The specified module could not be found. - C:/Ruby/lib/ruby/gems/1.8/gems
/mysql-2.8.1-x86-mswin32/lib/1.8/mysql_api.so

The problem for above error is, MySQL 5.1 client library doesn't play well with Rails.

Solution is

  • copy the downloaded file to C:\Ruby\bin (or wherever you installed Ruby)

  • restart MySQL server

Wednesday, October 14, 2009

Rails Set the Index Page

Follow the steps given bellow
1. Delete public/index.html
2. Add 'map.root :controller => ""' to routes.rb
3. and then of course create the controller with the action index.

Java Script Validations in RESTful Ruby on Rails Form

We can validate ruby on rails form using java script.It is show in bellow example

java script function

function validate()
{
//validation code
if (valid)
return true
else
return false
}

ruby on rails form

<% form_for(@patient_details,:html=>{:onsubmit=>"return validate();"}) do |f| %>
<%= f.error_messages %>
#form

<%end%>