Friday, October 9, 2009

How to integrate google maps with rails using ym4r _gm plugin

step 1:
first you need to install the plugin like this
 railsapp>
ruby script/plugin install svn://rubyforge.org/var/svn/ym4r/Plugins/GM/trunk/ym4r_gm
 
step 2:
put ym4r-gm.js file in javascripts directory(search in ym4r-gm plugin for js file)
step 3:
get googlemaps_api_key.yml file and put it in config folder(which consists of google maps api key)
step 4:
Mention like this in your controller which you want gmaps
require 'ym4r/google_maps/geocoding'
require 'rubygems'
require 'google_geocode' 
step 5:
In the view you need to mention like this otherwise it wont work:

<%= GMap.header %>
(application.rhtml)
 
<%= @map.to_html %>                                     
<%= @map.div(:width => 600,
:height => 400) %>(the view which u want)
 
step  6:
Mention like this in the method
@map = GMap.new("map_div")
@map.control_init(:large_map => true, :map_type => true)
@map.center_zoom_init([lat,lng], 13) 
 

Wednesday, September 9, 2009

FACT:1

Disable Extra Startup Programs:

There are certain programs that Windows will start every time you
boot up your system, and during the startup phase, they're all
competing for a slice of your CPU speed. Extra or unwanted items
in the startup list will definitely increase your startup time, perhaps
by several minutes. Some common examples are things related to
AOL, RealPlayer, Napster, instant messengers, and video managers.

If you're not sure about an item, no big deal. You can turn it off,
restart your PC, and see if everything seems to work. If not, you canalways
go back and re-enable an item in the Startup list. This tip alone should
speed up your start-up by 250%
. Here are is what you have to do:

1. Go to Start button  Run

2. Type "msconfig", without quotations

3. Hit enter key or click the OK button

4. A System Configuration Utility window will show up

5. Click the Startup tab

6. In the Startup tab you will see several boxes and some of them
will selected (checked). All you have to do is to uncheck
extra items that are of no use. If you run an antivirus
program it is not recommended to uncheck it.

7. After making you choices press the OK button, you will be
prompted to restart computer to apply changes.

8. After restarting your computer a dialogue will be displayed.
You can check the option for not showing this dialogue every
time your PC reboots.

Saturday, March 21, 2009

UPLOADING IMAGES WITH ATTACHMENT FU PLUGIN

step:1

install attachment_fu plugin
rails_app>
script/plugin install http://svn.techno-weenie.net/projects/plugins/attachment_fu/

step:2

install minimagick gem

rails_app>gem install minimagick(which is better in memory occuping from rest of it)

step:3
create a controller medias_controller.rb

def index
@medias = Media.find(:all)
end


def new
@media=Media.new
end

def create
@media = Media.new(params[:media])
if @media.save
flash[:notice] = "image successfully uploaded"
redirect_to :action => 'show'
else
logger.debug"%%%%%%%%%%%%% inside else"
flash[:notice]="image not uploaded"
redirect_to :action =>'show'
end
end



def show
@media = Media.find(params[:id])
end


def delete
@media = Media.find(params[:id])
@media.destroy
redirect_to :action =>'index'
end


step:4

in media.rb file

has_attachment :content_type => :image,
:storage => :file_system,
:min_size => 0,
:max_size => 1.megabytes,
:resize_to => '34x38',
:thumbnails => { :thumb => '15x15>' },
:processor => 'MiniMagick',
:path_prefix => "public/medias/"

validates_as_attachment

step:5

In views

views/medias/index.rhtml


<% for media in @medias %>
<%= link_to image_tag(media.public_filename(:thumb)),media.public_filename %>
<%= link_to 'Remove',{:action=> 'delete',:id => media.id},:confirm=> "Are you sure?" , :method => :post %>
<% end %>


views/medias/new.rhtml


<% form_for(:media,:url => {:action => :create }, :html => {:multipart => true }) do |f| %>

Select a photo to upload

Photo: <%= f.file_field 'uploaded_data' %>
<%= submit_tag 'Upload Photo' %>


views/medias/show.rhtml


<%= image_tag(@media.public_filename) %>

ACTION MAILER IN RAILS 2.0

STEP:1

In environment.rb file write it down like this at the end of the file

require 'smtp_tls'
ActionMailer::Base.default_content_type = "text/html"
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :login,(ur authentication method name here)
:user_name => "your gmail id ",
:password => "your gmail password ",
}

STEP:2

Include smtp_tls.rb file in lib folder

STEP:3

Follow this url then for
action mailerto work but dont change any configuration files as mentioned in the url for u

Monday, February 9, 2009