代码之家  ›  专栏  ›  技术社区  ›  Pablo Fernandez

Flash在Rails应用程序的Facebook重定向中无法存活

  •  3
  • Pablo Fernandez  · 技术社区  · 15 年前

    我有以下两种操作方法:

    def index
      puts "==index== flash: #{flash.inspect}"
    end
    
    def create
      flash[:notice] = "Blah"
      puts "==create== flash: #{flash.inspect}"
      redirect_to(:action => :index)
    end
    

    index.fbml.erb包含以下内容:

    <%= button_to_with_facebooker "Blah!", :action => :create %>
    

    该应用程序通过Facebook使用。我点击按钮,在执行创建的时候,flash包含了通知,但是之后它又是空的。它无法通过重定向。你知道这是怎么回事吗?

    1 回复  |  直到 15 年前
        1
  •  0
  •   Pablo Fernandez    15 年前

    我找到了一个解决办法。使用ActiveRecord存储会话时,添加

    ActionController::Dispatcher.middleware.delete Rack::FacebookSession
    ActionController::Dispatcher.middleware.insert_before(
      ActionController::Base.session_store,
      Rack::FacebookSession,
      ActionController::Base.session_options[:key])
    

    在初始化文件中,如config/initializers/session_store_fix_facebooker_session_key.rb

    This has been done on by someone else before he explained it on a message on the Facebooker group it doesn't work with the cookie session storage, Rail's default .