From 9462d19e42050b2d672cc1021bbbc5faf5e5e771 Mon Sep 17 00:00:00 2001 From: Andreas Mueller Date: Thu, 27 Jan 2011 10:40:31 +0100 Subject: [PATCH] specify :select in find to avoid :read_only The APN::Notification.find call returned read-only ActiveRecords, which can be prevented by specifying :select. -> see http://stackoverflow.com/questions/639171/what-is-causing-this-activerecordreadonlyrecord-error --- lib/apn_on_rails/app/models/apn/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/apn_on_rails/app/models/apn/app.rb b/lib/apn_on_rails/app/models/apn/app.rb index 81404900..49584be9 100644 --- a/lib/apn_on_rails/app/models/apn/app.rb +++ b/lib/apn_on_rails/app/models/apn/app.rb @@ -46,7 +46,7 @@ def self.send_notifications_for_cert(the_cert, app_id) end begin APN::Connection.open_for_delivery({:cert => the_cert}) do |conn, sock| - notifications = APN::Notification.find(:all, :conditions => conditions, :joins => " INNER JOIN apn_devices ON apn_devices.id = apn_notifications.device_id") + notifications = APN::Notification.find(:all, :select => "apn_notifications.*", :conditions => conditions, :joins => " INNER JOIN apn_devices ON apn_devices.id = apn_notifications.device_id") notifications.each do |noty| conn.write(noty.message_for_sending) noty.sent_at = Time.now