new2RoR
new2RoR

Reputation: 51

Using Eventmachine to write to a database and then using Rails to read it and display

I had wrote a Eventmachine server script which will receive location data from a remote GPS tracker. Now, I would like to ask the following: 1) How to write the location data into a MySQL database say by the name Position using Ruby? 2) Then, using a Rails framework to read from this SAME database called Position and display the location on a Google map. 3) If I run the Eventmachine server in the same Rails framework, how to specify the MySQL database in the Rails framework?

Thanks

Upvotes: 2

Views: 375

Answers (1)

Jerry C.
Jerry C.

Reputation: 496

Non-blocking ActiveRecord & Rails is a good starting point for doing async mysql. I recommend against receiving real-time data in the same process as your Rails process. It just leads to more headache in my past experience. Instead, I would have an Eventmachine process that's sole job is to listen for incoming GPS data, write that to your datastore, and then have Rails serve pages based on the datastore. You may also want to checkout Firehose.io or Faye as a way to push changes to your frontend.

Upvotes: 2

Related Questions