I am integrating some non-rail tables in a Rails application. Everything works very well, as I created the model:
class Change < ActiveRecord::Base
establish_connection(ActiveRecord::Base.configurations["otherdb_#{RAILS_ENV}"])
set_table_name "change"
end
That way I can use the model Changefor all existing entries with find, etc.
Now I would like to run some kind of notification when a record is added to the table. Since a model is never created using Change.newand Change.saveusing ActiveRecord::Observer, this is not an option.
Is there any way I can get my Rails code to be executed whenever a new entry is added? I looked at delayed_job, but I canβt tear my head off how to do it. I assume that it develops around cron-job, which selects all the lines that have been created since the job was last run, and then calls the corresponding Rails code for each line.
Update Currently, looking at Javan Whenever , it looks like it can solve the 'cron part' rails startup code.
source
share