I am using ruby on rails to use a gem to get the latest price for bitcoin. I am currently putting this in the application controller. @buy = coinbase.buy_price
. I want to use ajax or anything else to force this variable to update. I found a similar question to this (Rails 3 equivalent for periodically_call_remote) and the answer is close to what I need but I dont understand how to implement it. It has load('/controller/action');
so would I put application
as the controller? What would the action be? Thanks.
Asked
Active
Viewed 348 times
1
-
this will be the url you want to access for fetching information – Nitin Jain Jan 13 '14 at 04:30
-
@NitinJ Sorry I dont seem to understand. This is the application controller. There is no view/action associated to it! – nahtnam Jan 13 '14 at 04:33
1 Answers
2
You need to use javascript to setup a timer to make an ajax request every 15 seconds. The ajax request would be made to whatever URL is delivering the bitcoin information. From your description it sounds like that url will be an MVC style path, likely with your ControllerName/ActionName, whatever those may be.
When the ajax request returns the results (like a bitcoin price) then you would update whatever html element is showing your bitcoin price with the new data.

erikrunia
- 2,371
- 1
- 15
- 22
-
I got it working, but only after I put a action in the home controller. I have to figure out how to get it to work in the application controller. Thank you for the help. – nahtnam Jan 13 '14 at 05:12