# Link\_to\_remote problem

**URL:** <https://www.ruby-forum.com/t/link-to-remote-problem/105861>\
**Category:** Rails\
**Created:** [June 4, 2007, 12:42am UTC](https://www.ruby-forum.com/t/link-to-remote-problem/105861 "2007-06-04T00:42:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nightdog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7cd45c/32.png) [@nightdog](https://www.ruby-forum.com/u/nightdog)\
**Post date:** [June 4, 2007, 12:42am UTC](https://www.ruby-forum.com/t/link-to-remote-problem/105861/1 "2007-06-04T00:42:14Z")

</div>

hey everyone

I’m trying to implement a google map in my application using the ym4r  
framework.  
Accessing the action directly using the url /controller/action works  
fine.  
However, when i use link\_to\_remote or render\_component to display the  
action that has the map, it just renders a blank div.  
Does anyone have any idea on what could be happening or how should i  
load it properly?

Here’s how i’m declaring the link:

\<%= link\_to\_remote ‘Mapa’,  
:update =\> ‘main-window’,  
:method =\> ‘get’,  
:url =\> { :controller =\> ‘country’, :action =\> ‘index’} %\>

Thanks in advance,  
Ricardo Silveira C.

---

<div class="post-metadata">

**Author:** ![nightdog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7cd45c/32.png) [@nightdog](https://www.ruby-forum.com/u/nightdog)\
**Post date:** [June 4, 2007, 7:39am UTC](https://www.ruby-forum.com/t/link-to-remote-problem/105861/2 "2007-06-04T07:39:19Z")

</div>

the link appears to be functional. the problem is most likely in the  
action

---

<div class="post-metadata">

**Author:** ![nightdog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7cd45c/32.png) [@nightdog](https://www.ruby-forum.com/u/nightdog)\
**Post date:** [June 4, 2007, 2:34pm UTC](https://www.ruby-forum.com/t/link-to-remote-problem/105861/3 "2007-06-04T14:34:32Z")

</div>

On 6/3/07, Ricardo Silveira C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> load it properly?
> 
> Here’s how i’m declaring the link:
> 
> \<%= link\_to\_remote ‘Mapa’,  
> :update =\> ‘main-window’,  
> :method =\> ‘get’,  
> :url =\> { :controller =\> ‘country’, :action =\> ‘index’} %\>

Hi Ricardo,

I don’t think the problem is in your link\_to\_remote, if you have the  
id ‘main-window’ and is updating it with a ‘blank div’ that link is  
doing something. Are you sure you the output you are getting from  
country/index is what you want?

Can you give us the country/index action code and the view code too?

My advice would be: try it without ajax and do some tests, after you  
are sure of what is it doing, add ajax just to: “make it suck less”.

Suerte! 🙂

---

<div class="post-metadata">

**Author:** ![nightdog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7cd45c/32.png) [@nightdog](https://www.ruby-forum.com/u/nightdog)\
**Post date:** [June 4, 2007, 7:49pm UTC](https://www.ruby-forum.com/t/link-to-remote-problem/105861/4 "2007-06-04T19:49:07Z")

</div>

if i load localhost:3000/country/ the map appears just as it is supposed  
to.

here’s the code for country/index action and view:

country\_controller.rb:  
def index  
@map = GMap.new(“map\_div”)  
@map.control\_init(:large\_map =\> true,:map\_type =\> true)  
@map.center\_zoom\_init([37.735,-25.672],4)  
end

country/index.rhtml  
\<%= GMap.header(:with\_vml =\> false) %\>  
\<%= @map.to\_html %\>  
\<%= @map.div(:width =\> ‘500’, :height=\>‘400’) %\>

Thanks for answering!  
Ricardo Silveira C.

> I don’t think the problem is in your link\_to\_remote, if you have the  
> id ‘main-window’ and is updating it with a ‘blank div’ that link is  
> doing something. Are you sure you the output you are getting from  
> country/index is what you want?
> 
> Can you give us the country/index action code and the view code too?
> 
> My advice would be: try it without ajax and do some tests, after you  
> are sure of what is it doing, add ajax just to: “make it suck less”.
> 
> Suerte! 🙂

---

<div class="post-metadata">

**Author:** ![nightdog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7cd45c/32.png) [@nightdog](https://www.ruby-forum.com/u/nightdog)\
**Post date:** [June 4, 2007, 8:39pm UTC](https://www.ruby-forum.com/t/link-to-remote-problem/105861/5 "2007-06-04T20:39:48Z")

</div>

Hi Ricardo,

I was trying the same thing several weeks ago and it was giving me a  
hard time. I would check to make sure that your’re not getting any  
conflicts between the index.rhtml markup and the template that’s  
actually calling it.

Perhaps something strange is happening to the GMap header while it’s  
being rendered into a template other than index.rhtml:  
\<%= GMap.header %\>  
\<%= @map.to\_html %\>

I don’t know…I ended up just using a lame popup to display the map  
instead of ajax; I’ll go back and rework it and post the results here.

Jim

---

<div class="post-metadata">

**Author:** ![nightdog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7cd45c/32.png) [@nightdog](https://www.ruby-forum.com/u/nightdog)\
**Post date:** [June 4, 2007, 9:00pm UTC](https://www.ruby-forum.com/t/link-to-remote-problem/105861/6 "2007-06-04T21:00:01Z")

</div>

What do you mean by conflicts? i have  
\<%= GMap.header(:with\_vml =\> false) %\>  
declared on both the head of the layout and in country/index.rhtml,  
but i’ve tried every combination of header declarations with these two  
files to no avail.

I’ve uploaded my latest code to the site (with it’s respective google  
maps api key :)) to  
[http://sattagis1.dza.fc.ul.pt:3000/](http://sattagis1.dza.fc.ul.pt:3000/)  
if you want to take a look. The problematic link\_to\_remote to country/  
index is the word ‘Mapa’ in the second menu.

Thanks,  
Ricardo Silveira C.

---

<div class="post-metadata">

**Author:** ![nightdog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7cd45c/32.png) [@nightdog](https://www.ruby-forum.com/u/nightdog)\
**Post date:** [June 5, 2007, 12:30pm UTC](https://www.ruby-forum.com/t/link-to-remote-problem/105861/7 "2007-06-05T12:30:08Z")

</div>

For everyone trying the same thing:

Guilhem Vellut suggested changing  
\<%= @map.to\_html %\>  
to  
\<%= @map.to\_html :no\_load =\> true %\>

which fixed the situation.

Ricardo
