javascript - Ruby on Rails track location in background -
i started working ruby on rails 3 weeks ago, loving far need help.
i'm working on web app that, among others, tracks location of user , stores periodically in db. javascript getting location every minute working don't know how store location in db. script defined in application view. managed call update_location action defined in userscontroller using ajax post. lat long columns updated corectly page redirect occurs. want update process async , hidden user.
when tried using put ajax request (post _method=put) url not found user/:id/location_update.
i complete beginner ror , in web dev. p.s. using rails 4.
edit: using $.ajax or $.post _method : "put" , url /update_location triggers following 500 error
actionview::missingtemplate (missing template users/update_location, application/update_location {:locale=>[:en], :formats=>[...]}. searched in: * "/home/.../app/views" ):
my update_location action looks
def update_location @car = car.find(3) if @car.update_attributes(location_params) end end
the db getting updated still error.
i think want rails return jquery went well.. default it's trying render html jquery.
def update_location @car = car.find(3) @car.update_attributes(location_params) head :ok end
Comments
Post a Comment