In my controllers I have a respond_to block for both fbml and fbjs. I created the fbjs mime type in environment.rb: Mime::Type.register "application/javascript", :fbjs However, even if I specify fbjs in a parameter name format during AJAX post requests, it is being overwritten by Rails or Facebooker as FBML. I confirmed this by placing logger.debug params[:format] immediately before the respond_to block. The only way around it is to force it by creating a boolean parameter like from_fbjs. if params[:from_fbjs] request.format = :fbjs end Anyone else dealing with this?
Did the following to stop overwriting ajax requests as FBML vendor/plugins/facebooker/lib/facebooker/rails/controller.rb def set_fbml_format params[:format]="fbml" if request_is_for_a_facebook_canvas? params[:format]="fbjs" if request_is_facebook_ajax? end config/initializers Mime::Type.register ''text/html'', :fbml Mime::Type.register "application/javascript", :fbjs On Tue, Mar 18, 2008 at 6:11 PM, Jonathan Otto <jonathan.otto at gmail.com> wrote:> In my controllers I have a respond_to block for both fbml and fbjs. > > I created the fbjs mime type in environment.rb: > Mime::Type.register "application/javascript", :fbjs > > However, even if I specify fbjs in a parameter name format during AJAX > post requests, it is being overwritten by Rails or Facebooker as FBML. > I confirmed this by placing logger.debug params[:format] immediately > before the respond_to block. The only way around it is to force it by > creating a boolean parameter like from_fbjs. > > if params[:from_fbjs] > request.format = :fbjs > end > > Anyone else dealing with this? >
Hmm, that will break things like link_to_remote with update. What type of content are you sending back in your .fbjs block? It''s fbml as well, right? request.xhr? will work to differentiate between the two request types. Mike On Mar 18, 2008, at 6:27 PM, Jonathan Otto wrote:> Did the following to stop overwriting ajax requests as FBML > > vendor/plugins/facebooker/lib/facebooker/rails/controller.rb > > def set_fbml_format > params[:format]="fbml" if request_is_for_a_facebook_canvas? > params[:format]="fbjs" if request_is_facebook_ajax? > end > > config/initializers > > Mime::Type.register ''text/html'', :fbml > Mime::Type.register "application/javascript", :fbjs > > On Tue, Mar 18, 2008 at 6:11 PM, Jonathan Otto <jonathan.otto at gmail.com > > wrote: >> In my controllers I have a respond_to block for both fbml and fbjs. >> >> I created the fbjs mime type in environment.rb: >> Mime::Type.register "application/javascript", :fbjs >> >> However, even if I specify fbjs in a parameter name format during >> AJAX >> post requests, it is being overwritten by Rails or Facebooker as >> FBML. >> I confirmed this by placing logger.debug params[:format] immediately >> before the respond_to block. The only way around it is to force it by >> creating a boolean parameter like from_fbjs. >> >> if params[:from_fbjs] >> request.format = :fbjs >> end >> >> Anyone else dealing with this? >> > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk-- Mike Mangino http://www.elevatedrails.com
Why would it break it? It just demands that a FBJS request type must be responded to. To me, this seems more intuitive than responding to a FBJS with a fbml request type. On Tue, Mar 18, 2008 at 6:36 PM, Mike Mangino <mmangino at elevatedrails.com> wrote:> Hmm, that will break things like link_to_remote with update. > > What type of content are you sending back in your .fbjs block? It''s > fbml as well, right? > > request.xhr? will work to differentiate between the two request types. > > Mike > > > > > On Mar 18, 2008, at 6:27 PM, Jonathan Otto wrote: > > Did the following to stop overwriting ajax requests as FBML > > > > vendor/plugins/facebooker/lib/facebooker/rails/controller.rb > > > > def set_fbml_format > > params[:format]="fbml" if request_is_for_a_facebook_canvas? > > params[:format]="fbjs" if request_is_facebook_ajax? > > end > > > > config/initializers > > > > Mime::Type.register ''text/html'', :fbml > > Mime::Type.register "application/javascript", :fbjs > > > > On Tue, Mar 18, 2008 at 6:11 PM, Jonathan Otto <jonathan.otto at gmail.com > > > wrote: > >> In my controllers I have a respond_to block for both fbml and fbjs. > >> > >> I created the fbjs mime type in environment.rb: > >> Mime::Type.register "application/javascript", :fbjs > >> > >> However, even if I specify fbjs in a parameter name format during > >> AJAX > >> post requests, it is being overwritten by Rails or Facebooker as > >> FBML. > >> I confirmed this by placing logger.debug params[:format] immediately > >> before the respond_to block. The only way around it is to force it by > >> creating a boolean parameter like from_fbjs. > >> > >> if params[:from_fbjs] > >> request.format = :fbjs > >> end > >> > >> Anyone else dealing with this? > >> > > _______________________________________________ > > Facebooker-talk mailing list > > Facebooker-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/facebooker-talk > > -- > Mike Mangino > http://www.elevatedrails.com > > > >
It also means your templates must be action.fbjs.erb instead of action.fbml.erb, even though it is an fbml template. I''m not the way it works now is right, I just want to be able to share my .fbml.erb partials. Mike On Mar 18, 2008, at 6:59 PM, Jonathan Otto wrote:> Why would it break it? It just demands that a FBJS request type must > be responded to. To me, this seems more intuitive than responding to a > FBJS with a fbml request type. > > On Tue, Mar 18, 2008 at 6:36 PM, Mike Mangino > <mmangino at elevatedrails.com> wrote: >> Hmm, that will break things like link_to_remote with update. >> >> What type of content are you sending back in your .fbjs block? It''s >> fbml as well, right? >> >> request.xhr? will work to differentiate between the two request >> types. >> >> Mike >> >> >> >> >> On Mar 18, 2008, at 6:27 PM, Jonathan Otto wrote: >>> Did the following to stop overwriting ajax requests as FBML >>> >>> vendor/plugins/facebooker/lib/facebooker/rails/controller.rb >>> >>> def set_fbml_format >>> params[:format]="fbml" if request_is_for_a_facebook_canvas? >>> params[:format]="fbjs" if request_is_facebook_ajax? >>> end >>> >>> config/initializers >>> >>> Mime::Type.register ''text/html'', :fbml >>> Mime::Type.register "application/javascript", :fbjs >>> >>> On Tue, Mar 18, 2008 at 6:11 PM, Jonathan Otto <jonathan.otto at gmail.com >>>> wrote: >>>> In my controllers I have a respond_to block for both fbml and fbjs. >>>> >>>> I created the fbjs mime type in environment.rb: >>>> Mime::Type.register "application/javascript", :fbjs >>>> >>>> However, even if I specify fbjs in a parameter name format during >>>> AJAX >>>> post requests, it is being overwritten by Rails or Facebooker as >>>> FBML. >>>> I confirmed this by placing logger.debug params[:format] >>>> immediately >>>> before the respond_to block. The only way around it is to force >>>> it by >>>> creating a boolean parameter like from_fbjs. >>>> >>>> if params[:from_fbjs] >>>> request.format = :fbjs >>>> end >>>> >>>> Anyone else dealing with this? >>>> >>> _______________________________________________ >>> Facebooker-talk mailing list >>> Facebooker-talk at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/facebooker-talk >> >> -- >> Mike Mangino >> http://www.elevatedrails.com >> >> >> >>-- Mike Mangino http://www.elevatedrails.com