ticcoid
ticcoid

Reputation: 261

gmaps4rails: multiple objects (json)

In the controller I would like to try something like this:

@json = User.all.to_gmaps4rails
@json << Admin.all.to_gmaps4rails

But thats not gonna work. Is there a standard implementation how to deal with it?

Upvotes: 0

Views: 271

Answers (2)

Shanky Munjal
Shanky Munjal

Reputation: 671

(JSON.parse( User.all.to_gmaps4rails) + JSON.parse( Admin.all.to_gmaps4rails)).to_json

Upvotes: 0

apneadiving
apneadiving

Reputation: 115521

You could do:

json_hash  = JSON.parse(User.all.to_gmaps4rails)
json_hash2 = JSON.parse(Admin.all.to_gmaps4rails)
@json      = (json_hash + json_hash2).to_json

Not terrific, maybe I should patch the gem.

Upvotes: 1

Related Questions