I'm using Facebooker, and specifically the new Publisher class it has, with a Rails 1.2.6 app (hopefully I'll get us on Rails 2 sooner than later). But, Publisher uses some methods that are only available in Rails 2 it appears, as well as the mechanism it uses to look up Publisher view templates doesn't work properly in Rails 1.2. Also, link generation doesn't work quite right in all cases, so I have a fix for that too. Documenting my changes here for my own reference, as well as anyone else it may help.
For Publisher, I've made two changes to remedy these issues, both in
facebooker/lib/facebooker/rails/publisher.rb:
In the
initialize_template_class method, change the line:
returning ActionView::Base.new([template_root,File.join(template_root,self.class.controller_path)], assigns, self) do |template|
to instead be:
returning ActionView::Base.new(template_root, assigns, self) do |template|
This fixes the problem where the Publisher would look for views in a directory path that contained your publisher's name twice.
The second one is to change the
inherited method's call to
send! to instead simply call
send.
For the link generation, I tweaked the implementation of Facebooker's UrlRewriter#link_to_canvas? method, shown in entirety here:
def link_to_canvas?(params, options) option_override = options[:canvas] options[:only_path] = false if !option_override.nil? return false if option_override == false # important to check for false. nil should use default behavior option_override || @request.parameters["fb_sig_in_canvas"] == "1" || @request.parameters[:fb_sig_in_canvas] == "1"end
The result is that if the
canvas parameter is specified, then we force a full URL, instead of only a path (which is the default). This covers apps that have both a regular web application and a Facebook app, where you are generating links that point to one from the other (e.g. you're in Facebook, but generating a link that points to your regular web app).
Comments [0]