Skip to content

Commit

Permalink
specify :select in find to avoid :read_only
Browse files Browse the repository at this point in the history
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
andreasmueller committed Jan 27, 2011
1 parent e6e9b8d commit 9462d19
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/apn_on_rails/app/models/apn/app.rb
Expand Up @@ -46,7 +46,7 @@ def self.send_notifications_for_cert(the_cert, app_id)
end end
begin begin
APN::Connection.open_for_delivery({:cert => the_cert}) do |conn, sock| 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| notifications.each do |noty|
conn.write(noty.message_for_sending) conn.write(noty.message_for_sending)
noty.sent_at = Time.now noty.sent_at = Time.now
Expand Down

0 comments on commit 9462d19

Please sign in to comment.