Integrating Gmaps4rails into a Hobo App.

39 views
Skip to first unread message

paulj...@gmail.com

unread,
Sep 28, 2011, 9:38:07 PM9/28/11
to Hobo Users
I am trying to use gmaps4rails (https://github.com/apneadiving/Google-
Maps-for-Rails) in a Hobo app.

Lots of things seem to be working, but I cannot get the map to display
on the Index page.

In the simple straight sample Rails app, the call to the display
script goes at the bottom of the page. This pastie shows that call, on
Line 31:

http://pastie.org/2608726

And I have tried to insert that call a few places in my Hobo index
page, but I cannot get the map to show up. The application.dryml tag
definition is in this pastie:

http://pastie.org/2608748

(The before and after are scribbles that do appear in the page as
rendered.)

Any advice on the right method to get the map to show up on the index
page?

Thanks!

kevinpfromnm

unread,
Sep 29, 2011, 2:54:33 PM9/29/11
to hobo...@googlegroups.com
A quick glance at the project mentions the need for 2 yields in the header and footer and a few model additions and a controller addition that you don't show/mention in your pasties.

Realistically though there should be no way for hobo to interfere with this as it's being done in straight erb and doesn't seem to trod on any of the hobo added methods.

paulj...@gmail.com

unread,
Sep 29, 2011, 5:37:06 PM9/29/11
to Hobo Users
Thanks so much for the quick response, Kevin. I appreciate your time!

Sorry, I should have mentioned that I have made those edits - they
seemed more straightforward than this, so I did not include pasties of
them, but perhaps I should have mentioned. The pasties are below.

Seeing that I have done those, any further thoughts on getting the map
drawn?

Model:

http://pastie.org/2613465

Controller:

http://pastie.org/2613476

Base page definition

http://pastie.org/2613483

(is there a more specific place I should do this, rather than app-
wide, if it will only be used in a few views? And if so, how?)

kevinpfromnm

unread,
Sep 29, 2011, 6:41:14 PM9/29/11
to hobo...@googlegroups.com
I think I see where you might have gone wrong, you put the page update in the layout rather than by redefining/extending the hobo page tag right?  dryml views don't use standard rails layout files.  though it could be that you just put the content of the page tag, but the use of the <% yield %> right in the middle and the absence of params suggests otherwise.

kevinpfromnm

unread,
Sep 29, 2011, 6:44:10 PM9/29/11
to hobo...@googlegroups.com
oh, the second part.  if you're wanting this change in one or two places, you probably want to override the individual action (app/views/controller/action.dryml, i.e app/views/front/index.dryml).  If you use it multiple places, typically you define a tag containing the shared content in your app/views/taglibs/application.dryml file and call it from your overridden action.

Matt Jones

unread,
Sep 29, 2011, 8:45:39 PM9/29/11
to hobo...@googlegroups.com

On Sep 29, 2011, at 5:37 PM, paulj...@gmail.com wrote:

> Thanks so much for the quick response, Kevin. I appreciate your time!
>
> Sorry, I should have mentioned that I have made those edits - they
> seemed more straightforward than this, so I did not include pasties of
> them, but perhaps I should have mentioned. The pasties are below.
>
> Seeing that I have done those, any further thoughts on getting the map
> drawn?
>
> Model:
>
> http://pastie.org/2613465
>
> Controller:
>
> http://pastie.org/2613476

Setting an instance variable at the class level won't do what you expect - for instance, this:

class SomeClass

@some_var = 'FOO'

def index
puts @some_var
end
end

will *not* display 'FOO'. You'll need to override the actions you want to load the @json instance variable, like this:

class BpsController < ApplicationController
hobo_model_controller
auto_actions :all

def index
@json = Bp.all.to_gmaps4rails
hobo_index
end
end

--Matt Jones

paulj...@gmail.com

unread,
Sep 30, 2011, 4:39:40 PM9/30/11
to Hobo Users
Thanks, guys, working on those suggestions now.

On Sep 29, 5:45 pm, Matt Jones <al2o...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages