Permalink
Browse files

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
  • Loading branch information...
1 parent e6e9b8d commit 9462d19e42050b2d672cc1021bbbc5faf5e5e771 @andreasmueller committed Jan 27, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/apn_on_rails/app/models/apn/app.rb
View
2 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

0 comments on commit 9462d19

Please sign in to comment.