So I have an existing app & facebook app in same rails application, for now I have decided to go the route of creating a controller for facebook stuff (called FaceController). (setup is canvas, fbml) So I have: facebook config http://myurl:myport/face/ My controllers name is face, so I dont even need a manual route, for the landing page it works like a charm. but, when I try to make links: <fb:tab_item href="http://apps.facebook.com<%= url_for(:controller => ''face'', :action => "index", :only_path => true) %>" title="All Tasks"></fb:tab_item> This makes a url call to http://myurl:myport/face/face/index Any ideas for a cleaner setup? btw, is there a helper for making this link cleaner than this, or is this the best way to do it (borrowed from rfacebook example) thanks Joel
Shawn Van Ittersum
2008-Jan-25 17:48 UTC
[Facebooker-talk] simple routing & linking question
Hi Joel, This is the same problem I had, and I solved it by introducing a callback_path variable (like rfacebook has) and rewriting facebook_url_rewriting.rb. I''m working to make my changes backward-compatible with other users'' Facebooker configs so I can contribute the code back to the project. Shawn On Fri, 25 Jan 2008 09:55:27 -0500, Joel Nylund wrote:> So I have an existing app & facebook app in same rails application, > for now I have decided to go the route of creating a controller for > facebook stuff (called FaceController). > (setup is canvas, fbml) > > So I have: > > facebook config > http://myurl:myport/face/ > > My controllers name is face, so I dont even need a manual route, for > the landing page it works like a charm. > > but, when I try to make links: > > <fb:tab_item > href="http://apps.facebook.com<%= url_for(:controller => > ''face'', :action => "index", :only_path => true) %>" > title="All Tasks"></fb:tab_item> > > This makes a url call to http://myurl:myport/face/face/index > > Any ideas for a cleaner setup? > > btw, is there a helper for making this link cleaner than this, or is > this the best way to do it (borrowed from rfacebook example) > > thanks > Joel > > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk
I still don''t understand why this is necessary. Why do you guys use absolute urls? What''s wrong with using a relative url? What are you guys setting ENV[''FACEBOOKER_RELATIVE_URL_ROOT''] to in your env files? Joel: If you don''t want /face/face/index, why don''t you just leave off the :controller part of the url_for or (I''m guessing this is the issue) set your F...R_RELATIVE_URL_ROOT to "" (is it currently set to "face" also?)? BJ ----- BJ Clark the science department bjclark at scidept.com www.scidept.com On Jan 25, 2008, at 10:48 AM, Shawn Van Ittersum wrote:> Hi Joel, > > This is the same problem I had, and I solved it by introducing a > callback_path variable (like rfacebook has) and rewriting > facebook_url_rewriting.rb. I''m working to make my changes backward- > compatible with other users'' Facebooker configs so I can contribute > the code back to the project. > > Shawn > > On Fri, 25 Jan 2008 09:55:27 -0500, Joel Nylund wrote: >> So I have an existing app & facebook app in same rails application, >> for now I have decided to go the route of creating a controller for >> facebook stuff (called FaceController). >> (setup is canvas, fbml) >> >> So I have: >> >> facebook config >> http://myurl:myport/face/ >> >> My controllers name is face, so I dont even need a manual route, for >> the landing page it works like a charm. >> >> but, when I try to make links: >> >> <fb:tab_item >> href="http://apps.facebook.com<%= url_for(:controller => >> ''face'', :action => "index", :only_path => true) %>" >> title="All Tasks"></fb:tab_item> >> >> This makes a url call to http://myurl:myport/face/face/index >> >> Any ideas for a cleaner setup? >> >> btw, is there a helper for making this link cleaner than this, or is >> this the best way to do it (borrowed from rfacebook example) >> >> thanks >> Joel >> >> _______________________________________________ >> Facebooker-talk mailing list >> Facebooker-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/facebooker-talk > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk
This has been a frequently asked question and one that I''m working on in my book right now. Here are my recommendations: Don''t set a controller as your callback path. How will you create a development and production environment? Instead, make your callback url by the root of the server, i.e. http://myurl :myport/ Inside your routes.rb, do: map.facebook_root '''', :controller=>"face", :conditions=>{:canvas=>true} Put that before your root route for your main site Your urls can then be: <% fb_tabs do %> <%= fb_tab_item("All Tasks",facebook_root %> <% end %> If you want to link to your facebook page from a non-facebook view, do: <%= link_to "Check me out on facebook",facebook_root_url(:canvas=>true) %> If you want to link to your non-facebook app from facebook, simply do <%= link_to "Check out my non-facebook website", todo_path(:canvas=>false) %> Does that make sense? I know this stuff isn''t documented as well as it could be. There are people working on that. Please contribute tutorials. If you write one, let me know and I will give you access to the new http://www.facebooker-api.com site to upload it. SHAMELESS PLUG: I''m also writing a book on Facebook development with rails that will be available as a beta book. I''ll let everybody know when it is available. I''m hoping it will available within the next three weeks or so. Mike On Jan 25, 2008, at 8:55 AM, Joel Nylund wrote:> So I have an existing app & facebook app in same rails application, > for now I have decided to go the route of creating a controller for > facebook stuff (called FaceController). > (setup is canvas, fbml) > > So I have: > > facebook config > http://myurl:myport/face/ > > My controllers name is face, so I dont even need a manual route, for > the landing page it works like a charm. > > but, when I try to make links: > > <fb:tab_item > href="http://apps.facebook.com<%= url_for(:controller => > ''face'', :action => "index", :only_path => true) %>" > title="All Tasks"></fb:tab_item> > > This makes a url call to http://myurl:myport/face/face/index > > Any ideas for a cleaner setup? > > btw, is there a helper for making this link cleaner than this, or is > this the best way to do it (borrowed from rfacebook example) > > thanks > Joel > > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk-- Mike Mangino http://www.elevatedrails.com
I don''t wan to do absolute urls, I just cant figure out how to get it to work with relative urls (going to try Mike suggestion) my relative root env is set to my application name right now (http://apps.facebook.com/myapp --- mine is set to myapp) thanks Joel On Jan 25, 2008, at 1:05 PM, BJ Clark wrote:> I still don''t understand why this is necessary. > > Why do you guys use absolute urls? What''s wrong with using a relative > url? > > What are you guys setting ENV[''FACEBOOKER_RELATIVE_URL_ROOT''] to in > your env files? > > Joel: > If you don''t want /face/face/index, why don''t you just leave off > the :controller part of the url_for or (I''m guessing this is the > issue) set your F...R_RELATIVE_URL_ROOT to "" (is it currently set to > "face" also?)? > > BJ > ----- > BJ Clark > the science department > bjclark at scidept.com > www.scidept.com > > > On Jan 25, 2008, at 10:48 AM, Shawn Van Ittersum wrote: > >> Hi Joel, >> >> This is the same problem I had, and I solved it by introducing a >> callback_path variable (like rfacebook has) and rewriting >> facebook_url_rewriting.rb. I''m working to make my changes backward- >> compatible with other users'' Facebooker configs so I can contribute >> the code back to the project. >> >> Shawn >> >> On Fri, 25 Jan 2008 09:55:27 -0500, Joel Nylund wrote: >>> So I have an existing app & facebook app in same rails application, >>> for now I have decided to go the route of creating a controller for >>> facebook stuff (called FaceController). >>> (setup is canvas, fbml) >>> >>> So I have: >>> >>> facebook config >>> http://myurl:myport/face/ >>> >>> My controllers name is face, so I dont even need a manual route, for >>> the landing page it works like a charm. >>> >>> but, when I try to make links: >>> >>> <fb:tab_item >>> href="http://apps.facebook.com<%= url_for(:controller => >>> ''face'', :action => "index", :only_path => true) %>" >>> title="All Tasks"></fb:tab_item> >>> >>> This makes a url call to http://myurl:myport/face/face/index >>> >>> Any ideas for a cleaner setup? >>> >>> btw, is there a helper for making this link cleaner than this, or is >>> this the best way to do it (borrowed from rfacebook example) >>> >>> thanks >>> Joel >>> >>> _______________________________________________ >>> Facebooker-talk mailing list >>> Facebooker-talk at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/facebooker-talk >> _______________________________________________ >> Facebooker-talk mailing list >> Facebooker-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/facebooker-talk > > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk
Thanks to everyone for the responses, I think I will go with Mike''s suggestion, I implemented your approach and it seems to mess up my stand alone app, it seems to always try to route to facebook when I add: map.facebook_root '''', :controller=>"face", :conditions=>{:canvas=>true} to the top of my routes.rb file Also I have one question on the tabs How do I link to a method: on fb_tabs: for example I want to have a tab "My Tasks" that links to face controller mytasks method. If I do: <%= fb_tab_item("My Tasks", facebook_root_url + url_for(:controller => :face,:action => :my_tasks, :only_path => true)) %> it generates the url: http://apps.facebook.com/myapp//myapp/face/my_tasks My relative url is: ENV[''FACEBOOKER_RELATIVE_URL_ROOT''] = ''myapp'' As for your book, please hurry :) let me know if you want someone to read it. thanks Joel On Jan 25, 2008, at 1:10 PM, Mike Mangino wrote:> This has been a frequently asked question and one that I''m working > on in my book right now. Here are my recommendations: > > Don''t set a controller as your callback path. How will you create a > development and production environment? > > Instead, make your callback url by the root of the server, i.e. http://myurl > :myport/ > > Inside your routes.rb, do: > > map.facebook_root > '''', :controller=>"face", :conditions=>{:canvas=>true} > > Put that before your root route for your main site > > Your urls can then be: > <% fb_tabs do %> > <%= fb_tab_item("All Tasks",facebook_root %> > <% end %> > > If you want to link to your facebook page from a non-facebook view, > do: > > <%= link_to "Check me out on > facebook",facebook_root_url(:canvas=>true) %> > > If you want to link to your non-facebook app from facebook, simply do > > <%= link_to "Check out my non-facebook website", > todo_path(:canvas=>false) %> > > > Does that make sense? I know this stuff isn''t documented as well as > it could be. There are people working on that. Please contribute > tutorials. If you write one, let me know and I will give you access > to the new http://www.facebooker-api.com site to upload it. > > SHAMELESS PLUG: > > I''m also writing a book on Facebook development with rails that will > be available as a beta book. I''ll let everybody know when it is > available. I''m hoping it will available within the next three weeks > or so. > > Mike > > > On Jan 25, 2008, at 8:55 AM, Joel Nylund wrote: > >> So I have an existing app & facebook app in same rails application, >> for now I have decided to go the route of creating a controller for >> facebook stuff (called FaceController). >> (setup is canvas, fbml) >> >> So I have: >> >> facebook config >> http://myurl:myport/face/ >> >> My controllers name is face, so I dont even need a manual route, for >> the landing page it works like a charm. >> >> but, when I try to make links: >> >> <fb:tab_item >> href="http://apps.facebook.com<%= url_for(:controller => >> ''face'', :action => "index", :only_path => true) %>" >> title="All Tasks"></fb:tab_item> >> >> This makes a url call to http://myurl:myport/face/face/index >> >> Any ideas for a cleaner setup? >> >> btw, is there a helper for making this link cleaner than this, or is >> this the best way to do it (borrowed from rfacebook example) >> >> thanks >> Joel >> >> _______________________________________________ >> Facebooker-talk mailing list >> Facebooker-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/facebooker-talk > > -- > Mike Mangino > http://www.elevatedrails.com > > >
Mike & Other Friends, I played with this some more but no luck, no matter what I do, adding : map.facebook_root '''', :controller=>"face", :conditions=>{:canvas=>true} makes all requests to my app go to the facebook controller. I paired down my routes.rb to the basics, here it is: ActionController::Routing::Routes.draw do |map| map.facebook_root '''', :controller=>"face", :conditions=>{:canvas=>true} map.connect '''', :controller => ''account'', :action => ''home'' map.connect ''index.html'', :controller => ''account'', :action => ''home'' map.connect ''index.htm'', :controller => ''account'', :action => ''home'' # Install the default route as the lowest priority. map.connect ''/:controller/:action'' end If I go to localhost:3001 I get routed to: Processing FaceController#index (for 127.0.0.1 at 2008-01-25 22:09:07) [GET] Session ID: f513d7d336f467d9c6ca2f35e889dc7d Parameters: {"action"=>"index", "controller"=>"face"} any ideas? Is it just me, has anyone else tried this :conditions approach? I did get the tabs to work by doing: <%= fb_tab_item("My Tasks", facebook_root_url + url_for(:controller => :face,:action => :my_tasks, :only_path => true, :skip_relative_url_root => true)) %> the urls still have an extra slash, but they are working now! thanks Joel On Jan 25, 2008, at 3:08 PM, Joel Nylund wrote:> Thanks to everyone for the responses, I think I will go with Mike''s > suggestion, > > I implemented your approach and it seems to mess up my stand alone > app, it seems to always try to route to facebook when I add: > map.facebook_root > '''', :controller=>"face", :conditions=>{:canvas=>true} > > to the top of my routes.rb file > > Also I have one question on the tabs > > How do I link to a method: > > on fb_tabs: > > for example I want to have a tab "My Tasks" that links to face > controller mytasks method. > > If I do: > <%= fb_tab_item("My Tasks", facebook_root_url + url_for(:controller > => :face,:action => :my_tasks, :only_path => true)) %> > > it generates the url: > > http://apps.facebook.com/myapp//myapp/face/my_tasks > > My relative url is: > ENV[''FACEBOOKER_RELATIVE_URL_ROOT''] = ''myapp'' > > As for your book, please hurry :) let me know if you want someone to > read it. > > thanks > Joel > > On Jan 25, 2008, at 1:10 PM, Mike Mangino wrote: > >> This has been a frequently asked question and one that I''m working >> on in my book right now. Here are my recommendations: >> >> Don''t set a controller as your callback path. How will you create a >> development and production environment? >> >> Instead, make your callback url by the root of the server, i.e. http://myurl >> :myport/ >> >> Inside your routes.rb, do: >> >> map.facebook_root >> '''', :controller=>"face", :conditions=>{:canvas=>true} >> >> Put that before your root route for your main site >> >> Your urls can then be: >> <% fb_tabs do %> >> <%= fb_tab_item("All Tasks",facebook_root %> >> <% end %> >> >> If you want to link to your facebook page from a non-facebook view, >> do: >> >> <%= link_to "Check me out on >> facebook",facebook_root_url(:canvas=>true) %> >> >> If you want to link to your non-facebook app from facebook, simply do >> >> <%= link_to "Check out my non-facebook website", >> todo_path(:canvas=>false) %> >> >> >> Does that make sense? I know this stuff isn''t documented as well as >> it could be. There are people working on that. Please contribute >> tutorials. If you write one, let me know and I will give you access >> to the new http://www.facebooker-api.com site to upload it. >> >> SHAMELESS PLUG: >> >> I''m also writing a book on Facebook development with rails that >> will be available as a beta book. I''ll let everybody know when it >> is available. I''m hoping it will available within the next three >> weeks or so. >> >> Mike >> >> >> On Jan 25, 2008, at 8:55 AM, Joel Nylund wrote: >> >>> So I have an existing app & facebook app in same rails application, >>> for now I have decided to go the route of creating a controller for >>> facebook stuff (called FaceController). >>> (setup is canvas, fbml) >>> >>> So I have: >>> >>> facebook config >>> http://myurl:myport/face/ >>> >>> My controllers name is face, so I dont even need a manual route, for >>> the landing page it works like a charm. >>> >>> but, when I try to make links: >>> >>> <fb:tab_item >>> href="http://apps.facebook.com<%= url_for(:controller => >>> ''face'', :action => "index", :only_path => true) %>" >>> title="All Tasks"></fb:tab_item> >>> >>> This makes a url call to http://myurl:myport/face/face/index >>> >>> Any ideas for a cleaner setup? >>> >>> btw, is there a helper for making this link cleaner than this, or is >>> this the best way to do it (borrowed from rfacebook example) >>> >>> thanks >>> Joel >>> >>> _______________________________________________ >>> Facebooker-talk mailing list >>> Facebooker-talk at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/facebooker-talk >> >> -- >> Mike Mangino >> http://www.elevatedrails.com >> >> >> >
Shawn Van Ittersum
2008-Jan-26 03:35 UTC
[Facebooker-talk] simple routing & linking question
What book? Shawn On Fri, 25 Jan 2008 12:10:46 -0600, Mike Mangino wrote:> This has been a frequently asked question and one that I''m working on > in my book right now.
I''m writing Facebook Application Development with Rails for the Pragmatic Bookshelf. I hope it will be available in beta format next month. I''m hard at work making that happen. I''m actually working on the code for integrating Facebook and non-Facebook applications. I''ll make sure to spend a little time this weekend looking at using just a single controller or just several controllers. If you''re having problems, I''d ask you to: 1) Make sure you are on the latest version of Facebooker. The conditions=>{:canvas=>true} was committed within the last week. 2) Try to reproduce it using a very small application. If you can do that, either post the code somewhere or email it to me and I will make it available. 3) It would be really nice if you could write a failing test for the problem you are having. It''s better than just a sample app, but not required 4) Include a patch that fixes your failing tests. :) I know this can be a little frustrating, but please bare with us. Thanks Mike On Jan 25, 2008, at 9:35 PM, Shawn Van Ittersum wrote:> What book? > > Shawn > > On Fri, 25 Jan 2008 12:10:46 -0600, Mike Mangino wrote: >> This has been a frequently asked question and one that I''m working on >> in my book right now.-- Mike Mangino http://www.elevatedrails.com