Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Jun 6, 2012 · 4 comments

Comments

@picharras
Copy link

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
Copy link

alak commented Jun 10, 2012

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

@azcoov
Copy link

azcoov commented Jul 17, 2012

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
Copy link

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
Copy link

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 BY apn_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 BY apn_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 BY apn_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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants