Feed items

Multiple actions on one form

By using form tag we can define a action where we can submit the data and proceed further.
Now there are multiple submit button on the form and each required different action. So how to do that?
I found one easy solution for the this.

.....

function [...]

Labels in IE

Recently I develop one project which created by one of the plugin.
This project having pre configured css for the pages. Application is run well on all borwsers except IE.
In IE, labels are not displayed. Labels are displayed When I highlight on that by mouse.
This is a very strange problem for me because text is displayed [...]

auto_complete problem in ruby 1.9

Recently I upgrade my rails version from 2.3.2  to 2.3.4 and ruby version from 1.8 to 1.9 .
By changing version of ruby,  I was facing problem in auto complete functionality.
To solve the issue , I applied below patch in lib/autocomeplete_macro_helper.rb file

def auto_complete_result(entries, field, phrase = nil)
return unless entries
items = entries.map { |entry| content_tag("li", phrase ? [...]

Pop up window problem in IE

Recently I was having problem to open pop up window in IE browsers. Although it works properly in all other browsers.
In IE , window is open on self window rather than another window.
Finally I found the error in my code, and that was window name problem.
I defined the window name with space (window name). It [...]

File upload in ruby on rails.

There are lots of plugins available for upload files in ruby on rails.

file_column plugin:
attachment_fu
flex_image
upload_column
and many more

Accoding to  me, all these file are more useful for image uplaoding not other files like voice file, pdf and other.
So I made a defination which check following things and then upload a file on defined location.
1. File extension.
2. Mime [...]

Strip tags in Rails, Javascript and PHP

Strip tag function is used to remove html tags from the string.
Here I will show you that how to use strip tag in ruby on rails, javascript and php.
#PHP:
Example 1: Remove all html tags.

<?php
$str '

Test1.

text2

';
echo strip_tags($str);
?>

Example 2: Allow p and h1 html tag.

<?php
$str '

Test1.

text2

';
echo strip_tags($str,"

");
?>

#Ruby On Rails
Example 1: Remove all html tags
#model

class User < [...]

Find latitude-longitude in rails

Recently I posted a blog about  How to generate Google Maps in ruby on rails. In this blog, I used hard coded latitude-longitude values.
In real app hard coded values does not work, so we have to store latitude or longitude details in database or get it runtime.
By using geokits ,we can get latitude -longitude details [...]

Waiting for gg.google.com

When I was working on Google Maps API , I was getting error of “waiting for gg.google.com” on status bar.
Later on I found out that if script debugging is diabled, this problem can not raise.
So just disable script debugging from the firebug.

GPolygon in Gmaps

By using Gpolygon we can display a path on gmap. You need to just define order of locations(latitude,longitude) in this.
But you have to know How to generate Gmaps in ruby on rails
Create a polygone array #From Sri Lanka to Afghanistan

polyline=GPolyline.new([[7.880794,80.507813],
[22.792388,79.497070],
[29.874945, 69.345703],
[33.757228,65.522461]],
&quot;#ff0000&quot;,1,5.0)

Add into your map

@map.overlay_init(polyline)

You will get following output.

Google Maps in Ruby on Rails

To generate google maps in ruby on rails is so easy and simple. I had recently generated a few maps in my projects by  YM4R/GM plugin.
There are few steps that you need to follow to generate simple gmap.
1. Install YM4R/GM plugin in your rails app.
ruby script/plugin install svn://rubyforge.org/var/svn/ym4r/Plugins/GM/trunk/ym4r_gm
2. Copy  the javascripts files from YM4R/GM plugin [...]