Hi, I''m really not sure someone will be able to help me, but I have a problem with apn_on_rails. When I follow the exemple on the github page I have an error:>> device = APN::Device.create(:token => "XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX")>> notification = APN::Notification.new >> notification.device = device >> notification.badge = 5 >> notification.sound = true >> notification.alert = "foobar" >> notification.save My error: activeRecord::StatementInvalid: Mysql::Error: Column ''device_id'' cannot be null: INSERT INTO `apn_notifications` (`custom_properties`, `created_at`, `device_language`, `updated_at`, `device_id`, `sent_at`, `badge`, `errors_nb`, `sound`, `alert`) VALUES(NULL, ''2010-07-11 11:22:36'', NULL, ''2010-07-11 11:22:36'', NULL, NULL, 5, 0, 1, ''foobar'') My question is where to I set the device_id ? I can''t do: device.device_id = XXXXXXXX Greg -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi, Try this, i did it same way>> device = APN::Device.create(:token => "XXXXXXXX XXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX") >> notification = APN::Notification.new>> device.id= ''xxxxxxx''>> notification.device = device >> notification.badge = 5 >> notification.sound = true >> notification.alert = "foobar" >> notification.save * I tried the same way in my console.. See APN: Notifications table and the device id will be in APN: Device table. * On 11 July 2010 17:43, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > I''m really not sure someone will be able to help me, but I have a > problem with apn_on_rails. > When I follow the exemple on the github page I have an error: > > >> device = APN::Device.create(:token => "XXXXXXXX XXXXXXXX XXXXXXXX > XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX") > >> notification = APN::Notification.new > >> notification.device = device > >> notification.badge = 5 > >> notification.sound = true > >> notification.alert = "foobar" > >> notification.save > > > My error: > activeRecord::StatementInvalid: Mysql::Error: Column ''device_id'' cannot > be null: INSERT INTO `apn_notifications` (`custom_properties`, > `created_at`, `device_language`, `updated_at`, `device_id`, `sent_at`, > `badge`, `errors_nb`, `sound`, `alert`) VALUES(NULL, ''2010-07-11 > 11:22:36'', NULL, ''2010-07-11 11:22:36'', NULL, NULL, 5, 0, 1, ''foobar'') > > My question is where to I set the device_id ? > I can''t do: device.device_id = XXXXXXXX > > Greg > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Amit Kumar wrote:> Hi, > > Try this, i did it same way > > >>> device = APN::Device.create(:token => "XXXXXXXX XXXXXXXX XXXXXXXX > XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX") > >> notification = APN::Notification.new >>> device.id= ''xxxxxxx'' > >> notification.device = device > >> notification.badge = 5 > >> notification.sound = true > >> notification.alert = "foobar" > >> notification.save > * > I tried the same way in my console.. See APN: Notifications table and > the > device id will be in APN: Device table. > *Thank you, The device id is the iphone ID ? or the token is the iphone ID? When I save the notification, it device isnt storein the database ... ??? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
token is your iphone id On 11/07/2010, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Amit Kumar wrote: >> Hi, >> >> Try this, i did it same way >> >> >>>> device = APN::Device.create(:token => "XXXXXXXX XXXXXXXX XXXXXXXX >> XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX") >> >> notification = APN::Notification.new >>>> device.id= ''xxxxxxx'' >> >> notification.device = device >> >> notification.badge = 5 >> >> notification.sound = true >> >> notification.alert = "foobar" >> >> notification.save >> * >> I tried the same way in my console.. See APN: Notifications table and >> the >> device id will be in APN: Device table. >> * > > Thank you, > The device id is the iphone ID ? or the token is the iphone ID? > When I save the notification, it device isnt storein the database ... > ??? > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- --- Regards, Amit Kumar Ruby On Rails Consultant +91 9890654102 Blogsite: http://amitbaraik.blog.co.in/ This e-mail is confidential and may be legally privileged. If you are not the intended recipient, please notify the sender immediately and delete this e-mail. ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I mean device.id represents your token from apn_devices table. --- Regards, Amit Kumar Ruby On Rails Consultant +91 9890654102 Blogsite: http://amitbaraik.blog.co.in/ This e-mail is confidential and may be legally privileged. If you are not the intended recipient, please notify the sender immediately and delete this e-mail. ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? On 12 July 2010 01:22, Amit Kumar <amitbaraik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> token is your iphone id > > On 11/07/2010, Greg Ma <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > Amit Kumar wrote: > >> Hi, > >> > >> Try this, i did it same way > >> > >> > >>>> device = APN::Device.create(:token => "XXXXXXXX XXXXXXXX XXXXXXXX > >> XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX") > >> >> notification = APN::Notification.new > >>>> device.id= ''xxxxxxx'' > >> >> notification.device = device > >> >> notification.badge = 5 > >> >> notification.sound = true > >> >> notification.alert = "foobar" > >> >> notification.save > >> * > >> I tried the same way in my console.. See APN: Notifications table and > >> the > >> device id will be in APN: Device table. > >> * > > > > Thank you, > > The device id is the iphone ID ? or the token is the iphone ID? > > When I save the notification, it device isnt storein the database ... > > ??? > > > > -- > > Posted via http://www.ruby-forum.com/. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > > For more options, visit this group at > > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > > > > -- > --- > Regards, > Amit Kumar > Ruby On Rails Consultant > +91 9890654102 > Blogsite: http://amitbaraik.blog.co.in/ > > This e-mail is confidential and may be legally privileged. If you are > not the intended recipient, please notify the sender immediately and > delete this e-mail. > > > ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Amit Kumar wrote:> I mean device.id represents your token from apn_devices table.I don''t understand... I would it look like in production??? Greg -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hello, I know this issues is a couple of weeks old, but was still one of the more recent hits I found when looking for discussions of apn_on_rails. On Jul 12, 10:47 am, Greg Ma <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Amit Kumar wrote: > > I mean device.id represents your token from apn_devices table.This is really an ActiveRecord issue ... device.id is the database identifier of the record, not the APN token (which is "token"). In the code above, instead of assigning the to token to "device.id", assign it to "device.token". Then save the record: "device.save", and if you get back ''true'', you can procede with the rest of your code. As id is an int, you couldn''t put a string in there, which is what the token is. You''d get an error when trying to save, and the token field wouldn''t be populated. Just remember, unless you''re stepping off the ''golden path'' (and only do so when you need to and know what you''re doing), with ActiveRecord, the ''id'' field does not have any business data in it, it is just there to identify the record itself, in most cases, automatically assigned (possibly not with Oracle, but that''s another story). It can be useful to assign without having to actually retrieve a record, e.g., class User < ActiveRecord::Base belongs_to :office end Then, if you know the LA office is #3 e.g., you can do someuser.office_id = 3 someuser.save instead of someuser.office = Office.find_by_name("LA") someuser.save which will have to fetch another record, if Rails hasn''t cached it already. It is frequent in controllers you''ll have a record number rather than a record, coming back in the params from a form. But in many cases, you can pretty much ignore the ID field. Good luck, Craig> > I don''t understand... I would it look like in production??? > > Greg > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.