apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

empty json following tutorial #281

Closed alexbrand closed 11 years ago

alexbrand commented 11 years ago

I followed the tutorial and I am getting a map on my view.

However, the map is not showing my models.

I looked into the @json variable in my view, and it is empty

I am not sure what could be wrong.

Here is my model method:

def gmaps4rails_address
    # "#{self.address}, #{self.urbanization}, #{self.city.name}"
    "619 Johnson Street, Kingston, ON"
end

Here is my controller code:

def map
  @businesses = Business.all
  @json = @businesses.to_gmaps4rails

  respond_to do |format|
    format.html
    format.json {render json:@businesses}
  end
end

View code: (slim)

=gmaps4rails(@json)
=@json

@json = []

apneadiving commented 11 years ago

Your model is geocoded on save, simply.

On Oct 30, 2012, at 8:56 PM, alexbrand notifications@github.com wrote:

I followed the tutorial and I am getting a map on my view.

However, the map is not showing my models.

I looked into the @json variable in my view, and it is empty

I am not sure what could be wrong.

Here is my model method:

def gmaps4rails_address

"#{self.address}, #{self.urbanization}, #{self.city.name}"

"619 Johnson Street, Kingston, ON"

end Here is my controller code:

def map @businesses = Business.all @json = @businesses.to_gmaps4rails

respond_to do |format| format.html format.json {render json:@businesses} end end View code: (slim)

=gmaps4rails(@json) =@json @json = []

— Reply to this email directly or view it on GitHub.