【问题标题】:how can I conditionally change the default_url_options?如何有条件地更改 default_url_options?
【发布时间】:2013-06-07 03:09:29
【问题描述】:

因为我在 Facebook 的 Iframe 中运行 Rails 应用程序,所以我无法使用 Rails Session 变量。通过这样做,我能够成功地更改我的 url 以将会话详细信息作为参数包含在我的所有 url 链接中:

源代码:default_url_options and rails 3

class ApplicationController < ActionController::Base

  #each url should pass the signed_request hash in params
  def default_url_options(options = {})
    if 2 == 3
     { :parsed_signed_request => @parsed_signed_request}
    end
  end
end

然而,我的问题是 - 我如何有条件地更改我的默认 URL 以仅影响某些操作和视图。当前设置会导致未通过 @parsed_signed_request 变量的视图出现错误。

我的错误如下所示:undefined method ``reverse_merge`` for nil:NilClass

必须有一种方法只对单个操作执行此操作。

【问题讨论】:

    标签: ruby-on-rails-3 facebook


    【解决方案1】:

    如果 2 不等于 3,我认为您想返回一个空哈希。

    【讨论】:

      猜你喜欢
      • 2021-10-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-07
      • 1970-01-01
      • 2017-03-22
      • 1970-01-01
      • 2018-06-27
      • 2013-04-12
      相关资源
      最近更新 更多