PRX / apn_on_rails

Apple Push Notifications on Rails
http://rubydoc.info/github/PRX/apn_on_rails/master/frames
MIT License
538 stars 156 forks source link

Can't make app = APN::App.create(:apn_dev_cert => "MY_DEV_CERT.pem", :apn_prod_cert => "MY_PROD_CERT.pem") #51

Open picharras opened 12 years ago

picharras commented 12 years ago

Hi, I'm working with Ruby 1.9.2, Rails 3.2.3 and apn_on_rails 0.5.1 to implement push notifications in my application.

When I run:

app = APN::App.create(:apn_dev_cert => "MY_DEV_CERT.pem", :apn_prod_cert => "MY_PROD_CERT.pem")

I get the following error:

ActiveModel :: MassAssignmentSecurity :: Error: Can not mass-assign protected attributes: apn_dev_cert, apn_prod_cert

Does anyone know what does it mean? Thank you.

alak commented 12 years ago

Try app = APN::App.new app.apn_dev_cert = 'yourcert' app.save

azcoov commented 12 years ago

Yep that works. Here's my full call:

app = APN::App.new app.apn_dev_cert = 'apple_push_notification_development.pem' app.save device = APN::Device.create device.token = 'my token' device.app_id = 'my app id' notification = APN::Notification.new notification.device = device notification.badge = 5 notification.sound = true notification.alert = "foobar" notification.custom_properties = {:link => "http://www.prx.org"} notification.save

worked great!

psaravanan commented 11 years ago

Yes above work great thanks.

But "bundle exec rake apn:notifications:deliver --trace" give me the below error..

* Invoke apn:notifications:deliver (first_time) * Invoke environment (first_time) * Execute environment * Execute apn:notifications:deliver rake aborted! Unknown primary key for table apn_devices in model APN::Device. /home/saravanan/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/reflection.rb:366:in primary_key' /home/saravanan/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/reflection.rb:216:inassociation_primary_key' /home/saravanan/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/associations/association_scope.rb:58:in block in add_constraints' /home/saravanan/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/associations/association_scope.rb:39:ineach' /home/saravanan/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/associations/association_scope.rb:39:in each_with_index' /home/saravanan/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/associations/association_scope.rb:39:inadd_constraints' /home/saravanan/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/associations/association_scope.rb:31:in `scope'

Please advice!

psaravanan commented 11 years ago

Also while try "APN::App.first.send_notifications" Thats give below error..

Loading development environment (Rails 3.2.8) 1.9.3p194 :001 > APN::App.first.send_notifications APN::App Load (0.2ms) SELECT apn_apps.* FROM apn_apps LIMIT 1 APN::Device Load (0.6ms) SELECT apn_devices.* FROM apn_devices WHERE (app_id = 1) AND (apn_devices.>= 0) ORDER BYapn_devices. ASC LIMIT 1000 Mysql2::Error: Unknown column 'apn_devices.' in 'where clause': SELECT apn_devices.* FROM apn_devices WHERE (app_id = 1) AND (apn_devices.>= 0) ORDER BYapn_devices. ASC LIMIT 1000 ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'apn_devices.' in 'where clause': SELECT apn_devices.* FROM apn_devices WHERE (app_id = 1) AND (apn_devices.>= 0) ORDER BYapn_devices. ASC LIMIT 1000 from /home/saravanan/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in query' from /home/saravanan/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:inblock in execute'