Hi I am trying to use facebooker with an existing website that already has a model named ''User''. I therefore created a model called BkUser for use with facebooker. Also I have different controllers for all facebook requests. I am using acts_as_authenticated for handling login etc for my website and everytime a user is logged into my facebook app and tries to also browse the website (not through facebook), I see an error like undefined method `find_by_id'' for Facebooker::User:Class Application Trace lib/authenticated_system.rb:11:in `current_user'' lib/authenticated_system.rb:6:in `logged_in?'' app/controllers/main_controller.rb:14:in `index'' I am using sql session store for storing sessions. As I understand instead of User model, Facebooker::User model is being queried but I can''t understand why. Regards -- Prateek Dayal www.Muziboo.com get an audience
Christopher Bailey
2008-Apr-10 16:09 UTC
[Facebooker-talk] Facebooker and existing website?
One thing you may want to consider is using a combined user model. This way you can associate your regular (non-Facebook) users and their Facebook account. What''s cool about that, is that if they take some action on your regular web site, you can say update their Facebook profile box for your app. This is what we do, as do many sites. To do so, one approach at least is to add columns to your regular user model to store their Facebook persistent session and id, etc. The caveat is that you then need to add conditional logic to differentiate things at times. You also need to deal with synchronizing/associating their regular user with their Facebook user, but honestly this is pretty easy. In the app I''m working on, when they add the Facebook app, it tells the user they need to associate with their regular site account (we require this), and it sends them over to our site, they login, and in that process, we store off their Facebook infinite session key, and then redirect back to Facebook. Again, this is straight forward to do. With that setup, then you can just have a before filter on your Facebook controller(s) that check that the person has installed the app, by doing the equivalent of User.find_by_facebook_session_id (or whatever you called the column) or similar, etc. On Thu, Apr 10, 2008 at 6:40 AM, Prateek Dayal <prateek.dayal at gmail.com> wrote:> Hi > > I am trying to use facebooker with an existing website that already > has a model named ''User''. > > I therefore created a model called BkUser for use with facebooker. > Also I have different controllers for all facebook requests. > > I am using acts_as_authenticated for handling login etc for my website > and everytime a user is logged into my facebook app and tries to also > browse the website (not through facebook), I see an error like > > undefined method `find_by_id'' for Facebooker::User:Class > > Application Trace > > lib/authenticated_system.rb:11:in `current_user'' > lib/authenticated_system.rb:6:in `logged_in?'' > app/controllers/main_controller.rb:14:in `index'' > > I am using sql session store for storing sessions. As I understand > instead of User model, Facebooker::User model is being queried but I > can''t understand why. > > Regards > > -- > Prateek Dayal > > www.Muziboo.com > get an audience > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk >-- Christopher Bailey Cobalt Edge LLC http://cobaltedge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/facebooker-talk/attachments/20080410/224a7a0e/attachment.html
Hi Christopher, Thanks for the reply. My responses inline. On Thu, Apr 10, 2008 at 9:39 PM, Christopher Bailey <chris at cobaltedge.com> wrote:> One thing you may want to consider is using a combined user model. This way > you can associate your regular (non-Facebook) users and their Facebook > account. What''s cool about that, is that if they take some action on your > regular web site, you can say update their Facebook profile box for your > app. This is what we do, as do many sites.The problem with this one is that for my app its not necessary for people for facebook users to link their account (in fact most don''t even need to create accounts on my website). Another reason for not doing it was that I plan to support opensocial soon and therefore did not want to clutter up my user model too much. I have right now setup an association linking the accounts (if linked) I tried to dig deeper into the problem and I think the basic problem is that whenever i do User.find, rails finds Facebooker::User class before my regular User class. I tried doing ::User.find but that did not help either. Any way to set a default search order?> associate with their regular site account (we require this), and it sends > them over to our site, they login, and in that process, we store off their > Facebook infinite session key, and then redirect back to Facebook. Again, > this is straight forward to do.I have a slightly OT doubt on this. I was trying to setup a login and password form in my app that could be use to link accounts at any point. I noticed that fbml does not have a password field for forms. Is it mandatory to use iframe for this step in that case? Also can I use ensure_application_is_installed_by_facebook_user and other facebooker methods in the iframe to get facebook uid and link with account? Thanks a lot for your response Regards Prateek
On Thu, Apr 10, 2008 at 10:21 AM, Prateek Dayal <prateek.dayal at gmail.com> wrote:> > > I tried to dig deeper into the problem and I think the basic problem > is that whenever i do User.find, rails finds Facebooker::User class > before my regular User class. I tried doing ::User.find but that did > not help either. Any way to set a default search order?In my experience diving into these types of issues in the Rails source tends to be a serious time sync. Can you just change your User class to Member or something like that.> > I have a slightly OT doubt on this. I was trying to setup a login and > password form in my app that could be use to link accounts at any > point. I noticed that fbml does not have a password field for forms.You can do password fields with the fb:editor-custom tag. <fb:editor-custom label="TravelersTable Password"> <%= password_field_tag ''member[password]'', nil %> </fb:editor-custom> I think there is a helper for it.> > Is it mandatory to use iframe for this step in that case? Also can I > use ensure_application_is_installed_by_facebook_user and other > facebooker methods in the iframe to get facebook uid and link with > account?You can call those methods. They will cause redirects to happen if the user is not authenticated so you will want to special case them. Dave> > > Thanks a lot for your response > > Regards > Prateek > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/facebooker-talk/attachments/20080410/f1e3f424/attachment-0001.html
Hi David Thanks for the reply (and also for the excellent facebooker_tutorial on facebook). I am afraid things just got a bit more complicated for me.> In my experience diving into these types of issues in the Rails source tends > to be a serious time sync. Can you just change your User class to Member or > something like that.On some more inspection, I found out the following 1. If I start my webserver and browse the website, everything works fine 2. If i access the facebook app and then try to browse the website, I start getting error for all models that I have. For example, I have a group model and I do a Group.find() to load a page and I get an error on Facebooker::Group:Class. Looks like everything is being referenced as Facebooker:: Could this be related to any facebooker setting? I have a feeling that the problem is not about two User class but about everything being referenced in Facebooker module Thanks again for helping me out Regards Prateek> > > > > > > > > > I have a slightly OT doubt on this. I was trying to setup a login and > > password form in my app that could be use to link accounts at any > > point. I noticed that fbml does not have a password field for forms. > > You can do password fields with the fb:editor-custom tag. > > <fb:editor-custom label="TravelersTable Password"> > <%= password_field_tag ''member[password]'', nil %> > </fb:editor-custom> > > I think there is a helper for it. > > > > > Is it mandatory to use iframe for this step in that case? Also can I > > use ensure_application_is_installed_by_facebook_user and other > > facebooker methods in the iframe to get facebook uid and link with > > account? > > You can call those methods. They will cause redirects to happen if the user > is not authenticated so you will want to special case them. > > Dave > > > > > > > > Thanks a lot for your response > > > > Regards > > Prateek > > > > > > > > > > _______________________________________________ > > Facebooker-talk mailing list > > Facebooker-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/facebooker-talk > > > >-- Prateek Dayal www.Muziboo.com get an audience
On Thu, Apr 10, 2008 at 2:01 PM, Prateek Dayal <prateek.dayal at gmail.com> wrote:> Hi David > > Thanks for the reply (and also for the excellent facebooker_tutorial > on facebook). I am afraid things just got a bit more complicated for > me. > > > In my experience diving into these types of issues in the Rails source > tends > > to be a serious time sync. Can you just change your User class to > Member or > > something like that. > > On some more inspection, I found out the following > > 1. If I start my webserver and browse the website, everything works fine > 2. If i access the facebook app and then try to browse the website, I > start getting error for all models that I have. For example, I have a > group model and I do a Group.find() to load a page and I get an error > on Facebooker::Group:Class. Looks like everything is being referenced > as Facebooker:: > > Could this be related to any facebooker setting? I have a feeling that > the problem is not about two User class but about everything being > referenced in Facebooker moduleI use the restful_authentication plugin (which I think borrows from acts_as_authenticated), have a model named "User" and use the facebooker plugin without these issues, so I am fairly confident they can be resolved. Are you sure you''re not doing a stray "include" of the Facebooker module somewhere? That''s kind of what it sounds like. AuthenticatedSystem is designed to be used via an ''include'' in application.rb, but the facebooker plugin is not. Also, FWIW, I did end up creating an evil twin<http://errtheblog.com/posts/67-evil-twin-plugin>class of authenticated_system so that I could rewrite how login_from_session works, and allow it to auto-create facebook users if one is present. If you think that code would be useful to you, let me know and I can send it to you. I don''t think it would help with this particular problem, though. Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/facebooker-talk/attachments/20080410/e446f79f/attachment-0001.html
Hi Tom Thanks a ton I was actually doing an ''include Facebooker'' in one of the models where i wanted to do ''include Facebooker::Helper'' to use some of the facebooker helpers to create some feeds etc for my application I am only slowly and painfully realizing the importance of having some kind of test coverage. In a rush to write more code I have been skipping tests and lately it has been coming back to bite me :) Thanks again Regards Prateek On Fri, Apr 11, 2008 at 2:51 AM, Tom Lianza <tom at lianza.org> wrote:> On Thu, Apr 10, 2008 at 2:01 PM, Prateek Dayal <prateek.dayal at gmail.com> > wrote: > > > Hi David > > > > Thanks for the reply (and also for the excellent facebooker_tutorial > > on facebook). I am afraid things just got a bit more complicated for > > me. > > > > > > > In my experience diving into these types of issues in the Rails source > tends > > > to be a serious time sync. Can you just change your User class to > Member or > > > something like that. > > > > On some more inspection, I found out the following > > > > 1. If I start my webserver and browse the website, everything works fine > > 2. If i access the facebook app and then try to browse the website, I > > start getting error for all models that I have. For example, I have a > > group model and I do a Group.find() to load a page and I get an error > > on Facebooker::Group:Class. Looks like everything is being referenced > > as Facebooker:: > > > > Could this be related to any facebooker setting? I have a feeling that > > the problem is not about two User class but about everything being > > referenced in Facebooker module > > I use the restful_authentication plugin (which I think borrows from > acts_as_authenticated), have a model named "User" and use the facebooker > plugin without these issues, so I am fairly confident they can be resolved. > > Are you sure you''re not doing a stray "include" of the Facebooker module > somewhere? That''s kind of what it sounds like. AuthenticatedSystem is > designed to be used via an ''include'' in application.rb, but the facebooker > plugin is not. > > Also, FWIW, I did end up creating an evil twin class of authenticated_system > so that I could rewrite how login_from_session works, and allow it to > auto-create facebook users if one is present. If you think that code would > be useful to you, let me know and I can send it to you. I don''t think it > would help with this particular problem, though. > Tom >-- Prateek Dayal www.Muziboo.com get an audience
I would really like to see a full stack trace on this. Also, what version of Rails are you running? Rails has some problems with class names existing in two namespaces. It can sometimes cause the problems you are seeing. That said, I don''t see these issues on any of my apps either. Mike On Apr 10, 2008, at 4:01 PM, Prateek Dayal wrote:> Hi David > > Thanks for the reply (and also for the excellent facebooker_tutorial > on facebook). I am afraid things just got a bit more complicated for > me. > >> In my experience diving into these types of issues in the Rails >> source tends >> to be a serious time sync. Can you just change your User class to >> Member or >> something like that. > > On some more inspection, I found out the following > > 1. If I start my webserver and browse the website, everything works > fine > 2. If i access the facebook app and then try to browse the website, I > start getting error for all models that I have. For example, I have a > group model and I do a Group.find() to load a page and I get an error > on Facebooker::Group:Class. Looks like everything is being referenced > as Facebooker:: > > Could this be related to any facebooker setting? I have a feeling that > the problem is not about two User class but about everything being > referenced in Facebooker module > > Thanks again for helping me out > > Regards > Prateek > > > >> >> >>> >>> >>> >>> I have a slightly OT doubt on this. I was trying to setup a login >>> and >>> password form in my app that could be use to link accounts at any >>> point. I noticed that fbml does not have a password field for forms. >> >> You can do password fields with the fb:editor-custom tag. >> >> <fb:editor-custom label="TravelersTable Password"> >> <%= password_field_tag ''member[password]'', nil %> >> </fb:editor-custom> >> >> I think there is a helper for it. >> >>> >>> Is it mandatory to use iframe for this step in that case? Also can I >>> use ensure_application_is_installed_by_facebook_user and other >>> facebooker methods in the iframe to get facebook uid and link with >>> account? >> >> You can call those methods. They will cause redirects to happen if >> the user >> is not authenticated so you will want to special case them. >> >> Dave >>> >>> >>> >>> Thanks a lot for your response >>> >>> Regards >>> Prateek >>> >>> >>> >>> >>> _______________________________________________ >>> Facebooker-talk mailing list >>> Facebooker-talk at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/facebooker-talk >>> >> >> > > > > -- > Prateek Dayal > > www.Muziboo.com > get an audience > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk-- Mike Mangino http://www.elevatedrails.com