Jump to content

The ultimate community for Ruby on Rails developers.


Photo

How would I define a model that recognizes when the content of a page changes?

ruby rails activerecord model

  • Please log in to reply
2 replies to this topic

#1 ghobs91

ghobs91

    Passenger

  • Members
  • 1 posts

Posted 14 January 2014 - 07:48 PM

One of my static pages displays items using eBay's API, based on criteria that the user provides. How can I define a function within a model that detects when the contents of this page change (ie. when a new item in their criteria is listed on eBay), and then interacts with ActionMailer to notify them? 



#2 stevieing

stevieing

    Dispatcher

  • Members
  • 40 posts

Posted 15 January 2014 - 09:52 AM

It would probably be better to put that function elsewhere as it involves a http request/response.

 

You would need to set up a background job that would poll eBay maybe via a webservice...

 

Sorry I have no experience of this so can't give you any more detail. If you search for background jobs on railscasts there are a few examples.

 

Regards

 

Steve.



#3 panzhuli

panzhuli

    Passenger

  • Members
  • 3 posts

Posted 20 January 2014 - 12:59 AM

Unless you're also storing EBay's content in your db, I would recommend handling it via AJAX and use a javascript framework to update elements on the screen. I'd think this is a front-end job rather than back-end...







Also tagged with one or more of these keywords: ruby, rails, activerecord, model

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users