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 7871277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:51:17+00:00 2026-06-03T01:51:17+00:00

I am using gmaps4rails and now when I click on a marker appears information

  • 0

I am using gmaps4rails and now when I click on a marker appears information from the database, I need a putting a link inside the marker. How do I?

Model:

def gmaps4rails_address
  city
end

def gmaps4rails_infowindow
   "<h4>#{city}</h4>"  
end

Controller:

def index
  @postos = Posto.all
  @markers = Posto.all.to_gmaps4rails  

  @json = Posto.all.to_gmaps4rails  do |posto, marker|
    marker.json "\"id\": #{posto.id}"
  end  
  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @postos }
  end
end
  • 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-03T01:51:18+00:00Added an answer on June 3, 2026 at 1:51 am

    I don’t recommend you use the gmaps4rails_infowindow method: view details shouldn’t be given at the model layer.

    You should rather configure the infowindow in the controller, using a partial:

    @json = Posto.all.to_gmaps4rails do |posto, marker|
      marker.infowindow render_to_string(:partial => "/path_to/your_template", :locals => { needed_locales })
    end
    

    Details are in the gem’s wiki. (you could even use js templates but it’s not the question and it’s explained in the wiki as well)

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

Sidebar

Related Questions

I'm using gmaps4rails and I need to execute javascript inside a marker's info window.
I'm using Gmaps4rails to display a map of properties. The properties model has an
Using gcc and ld on x86_64 linux I need to link against a newer
Is it possible to do something like this marker styling using Gmaps4rails gem. I`ve
I'm using gmaps4rails and I have a good amount of markers, now when I
I am using Gmaps4rails. It's working really fine. But now I got an issue
I'm using gem gmaps4rails and gem cells both of which by themselves work brilliantly.
I've been using the gmaps4rails gem for a while in rails 3.1 and it
Using Rails 3.2.0 with haml and sass: I Would like to link an external
I'm using gmaps4rails on my project. This gem works amazing but i have a

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.