Topic: Fix for Ym4r bug with rails 2.2.2

If you encountered a bug with the ym4r plugin and ruby on rails 2.2.2 here there is a solution.
We have worked for this a while but we've finally solved it.

If you encount this error => undefined method 'relative_url_root' for ActionContoller::AbstractRequest:Class

You have to go to vendor/plugins/ym4r_gm/gm_plugin/map.rb, comment this line ( for me it was 36 )

a << "script src=\"#{ActionController::AbrastractRequest.relative_url_root}/javascript/ym4r-gm.js\" type=\"text/javascript\"> </script>\n" unless option[:without_js]

and substitude the string "#{ActionController::AbstractRequest.relative_url_root}" with "#{ActionController::Base.relative_url_root}" in a new cleared line.

I hope it will be usefull for others.

eTr && sgtbash ( University of Catania, Sicily , Italy )

Re: Fix for Ym4r bug with rails 2.2.2

Thanks for this - big help.

Two clarifications for anyone following:

at least on my version of ym4r_gm the file that needs to be edited was in:
vendor/plugins/ym4r_gm/lib/map.rb

Also, you should just copy that whole line to a new line below it, comment out the original version of it, and then change "AbstractRequest" to "Base" on the uncommented version of the line.

Last edited by tomkarlo (2008-12-04 12:02:31)

Re: Fix for Ym4r bug with rails 2.2.2

Thanks a lot !!!

I do appreciate your solution.

Saludos

Douglas

Re: Fix for Ym4r bug with rails 2.2.2

Hi,

I would like for your help in this case; it happened that it actually worked for me in the development environment(localhost:3000), but when I deployed to the production server, (www.arondeir.com) it gives me the same error.
Do you have any ideas about it?, do your solution work in production and dev environment ??

Thanks in advance

Douglas

Re: Fix for Ym4r bug with rails 2.2.2

Hola,

I just finished fixing the problem on the production server,  what I did is that I removed the production server url at the /conf/gmaps_api_key
I only left the key for the domain given by google when register; git and deploy, and everything works fine.
Thanks again for your initial tips.

Saludos

Douglas

Re: Fix for Ym4r bug with rails 2.2.2

Thakns sgtbash. I did some different way with your solution.

I made a file named "PatchYm4rGM.rb" in config/initializer directory and copy GMap's header method. Then applied your solution. :-)

class GMap
  def self.header(options = {})
    options[:with_vml] = true unless options.has_key?(:with_vml)
    options[:hl] ||= ''
    options[:local_search] = false unless options.has_key?(:local_search)
    api_key = ApiKey.get(options)
    a = "<script src=\"http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=#{api_key}&amp;hl=#{options[:hl]}\" type=\"text/javascript\"></script>\n"
    a << "<script src=\"#{ActionController::Base.relative_url_root}/javascripts/ym4r-gm.js\" type=\"text/javascript\"></script>\n" unless options[:without_js]
    a << "<style type=\"text/css\">\n v\:* { behavior:url(#default#VML);}\n</style>" if options[:with_vml]
    a << "<script src=\"http://www.google.com/uds/api?file=uds.js&amp;v=1.0\" type=\"text/javascript\"></script>" if options[:local_search]
    a << "<script src=\"http://www.google.com/uds/solutions/localsearch/gmlocalsearch.js\" type=\"text/javascript\"></script>\n" if options[:local_search]
    a << "<style type=\"text/css\">@import url(\"http://www.google.com/uds/css/gsearch.css\");@import url(\"http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css\");}</style>" if options[:local_search]
    a
  end
end

With this way, I don't have to modify plugin directory, so don't worry about plugin update. :-)

Re: Fix for Ym4r bug with rails 2.2.2

Hi

I am using Rails v 2.2.2.  I downloaded the plugin and it had the line already changed. But I still get the error?

Any Ideas

Thanks

Re: Fix for Ym4r bug with rails 2.2.2

HI

#I am using Rails v 2.2.2.  I downloaded the plugin and it had the line already changed. But I still get the error?#


I have the same problem. Help please.
______________
Total video converter 3.50 keygen is a exelect software to convert video.

Last edited by Bigrad (2009-10-13 21:33:12)

Re: Fix for Ym4r bug with rails 2.2.2

Hi, maybe this will help,

In my case I had constraints preventing me from upgrading to a later version of Rails.

So in ...vendor/plugins/ym4r_gm/lib/gm_plugin/map.rb on line 36, I changed #{ActionController::Base.relative_url_root} to #{ENV['RAILS_ROOT']}.

That did the trick.

Re: Fix for Ym4r bug with rails 2.2.2

Very useful and informative post... Thanks for sharing here link... Its content is so informative.....






www.plagiarismsoftware.org | http://www.six-sigma-certification.net/
www.accidentinjuryhelplines.co.uk/claim-type/slip-trip-or-fall.html

Last edited by alexemil5 (2013-06-22 02:27:01)