Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8170923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:17:37+00:00 2026-06-06T21:17:37+00:00

I have a remote: true call in my Rails 3 app controller HotelsController ,

  • 0

I have a remote: true call in my Rails 3 app controller HotelsController, which executes show_map action. Pretty simple.

<%= link_to "Map", show_hotel_map_path(@hotel.id), remote: true %>
<div id="hotel_map"></div>

show_hotel_map action is pretty basic

def show_hotel_map
  @hotel = Hotel.find(params[:id])
  respond_to do |format|
    format.html
    format.js
  end
end

show_hotel_map.js.erb is meant to render a partial map within JQuery-UI dialog with rendered Google Maps map

$("#hotel_map").dialog({
  autoOpen: true,
  height: 'auto',
  width: 'auto',
  modal: true,
  closeOnEscape: true,
  position: 'center',
  resizable: false,
  title: "Map",
  open: function(){
      $("#hotel_map").html("<%= escape_javascript(render partial: "map") %>")
  }
});

_map.html.erb partial does nothing but executes render_map helper

<%= render_map %>

render_map helper does all the stuff with rendering a map with Gmaps4Rails gem

module HotelsHelper

  def render_map
    if @hotel.address.latitude && @hotel.address.longitude
      map = @hotel.address.to_gmaps4rails
    else
      geo = Gmaps4rails.geocode("#{@hotel.continent.name}, #{@hotel.country.name}, #{@hotel.location.name}")[0]
      map = [{lat: geo[:lat], lng: geo[:lng]}].to_json
    end
    gmaps(:markers => { :data => map, :options => { :draggable => true } })
  end
end

The problem is that Gmaps4Rails gem renders some javascript for proper Google Maps handling, but apparently this javascript is being truncated by escape_javascript call from show_map.js.erb view. So when I click "Map" link, JQuery-UI dialog is being rendered, but it does not have any payload, since no Javascript was executed. render_map helper works perfectly by itself, so I guess that’s not a problem with Gmaps4Rails gem. Is there any workarounds so I can execute that javascript? I can think of few hacks, but maybe there is more Rail-ish way to do it?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:17:40+00:00Added an answer on June 6, 2026 at 9:17 pm

    Okay, to whom it may concern, I solved it using UJS technique described in Gmaps4Rails wiki

    https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Using-with-UJS

    It is not very DRY but I guess there’s not many other options.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a RoR app running rails 2.3.8 which makes use of the Rails
I have an ASP.NET application that executes a WMI call to a remote system.
So I have a simple ajax call to a page: = link_to 'click me',
I know the app servers like Websphere and Weblogic have remote deployment capabilities that
I am using rails 2.3 and have a problem. I have remote form, and
I have a remote call that I make and I am wondering where it
I have a remote actor (client) which is registering with another remote actor (server)
I have a remote server like below which already has an initialized class and
I have a remote form with hand-made buttons using tags. I'm using data-remote=true in
I have a link marked :remote => true that makes a get request to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.