0

I am trying to call my new/create form in an infowindow in google maps (gmaps4rails)

My current code is :

  def index
    @locations = Location.all
    @hash = Gmaps4rails.build_markers(@locations) do |location, marker|
      marker.lat location.latitude
      marker.lng location.longitude
      #marker.infowindow location.title
      marker.infowindow render new_data
    end
  end

The first problem that I have is that I don't know how to render a path from a different view. Meaning, this controller is a locations controller and I am trying to render a data form based on this route

 new_data GET    /data/new(.:format)      datas#new

I tried to check rendering with the location's form, but than I am getting that @location is nil. I know that this will be the next problem I will encounter once I figure out the rendering, so I will appreciate inputs on this one as well.

Quantico
  • 2,398
  • 7
  • 35
  • 59
  • I would render a partial rather than a whole view. Check out this: http://stackoverflow.com/questions/1767876/rendering-partials-from-one-controllers-view-to-another-controllers-view-in-rail – ussferox Nov 17 '13 at 03:13
  • render :action => "data/new" will result in Missing template locations/data/new, and the redirect_to breaks due to too many calls – Quantico Nov 17 '13 at 03:21
  • https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Json-builder – apneadiving Nov 17 '13 at 15:15

1 Answers1

0

looks like you're forgetting a slash. i think it should be

render :action => "/data/new". 

also, are you trying to render a partial (i.e. the filename is "_new.html.erb") or the actual full page (which would be "new.html.erb")?

ussferox
  • 490
  • 5
  • 10
  • this will result in Missing template locations/data/new – Quantico Nov 17 '13 at 03:39
  • I am trying to call the action new that should render the _form. – Quantico Nov 17 '13 at 03:39
  • na you need to render the partial itself if you're not trying to go entirely to a new page, which would be _form (and then define in your locations controller that it should be for a new data object), unless your data new action is only rendering a partial and nothing else (but I kind of feel like that's a bit circuitous). But why don't you just render the partial in your javascript if every single infowindow will have a new data form? – ussferox Nov 17 '13 at 03:56