Ruby on rails 将参数传递到rails中的iframe不工作
我是铁路迷,所以我知道我可能完全错过了一些东西。我正试图通过我的产品控制器将url传递到iframe 这是我的设置 产品控制员Ruby on rails 将参数传递到rails中的iframe不工作,ruby-on-rails,Ruby On Rails,我是铁路迷,所以我知道我可能完全错过了一些东西。我正试图通过我的产品控制器将url传递到iframe 这是我的设置 产品控制员 def open_url @url = params[:url] end def show @url = Product.find(params[:id]) end index.html.erb <%= link_to "More Info", open_path(url: "http://www.ceratobouti
def open_url
@url = params[:url]
end
def show
@url = Product.find(params[:id])
end
index.html.erb
<%= link_to "More Info", open_path(url: "http://www.ceratoboutique.com" + product.destination_url) %>
<%= link_to "More Info", product_path(product) %>
一、 我检查了这两个问题
但我还是迷路了,url被传递到浏览器,但它似乎没有传递到控制器中的@url变量
调试转储
!!ruby/hash:ActionController::Parameters
网址:
控制器:产品
操作:打开url
我决定坚持rails惯例,并使其成为restful链接。我仍然不知道为什么最初的实现不起作用,但它在控制器中使用show方法起作用 控制器
def open_url
@url = params[:url]
end
def show
@url = Product.find(params[:id])
end
index.html.erb
<%= link_to "More Info", open_path(url: "http://www.ceratoboutique.com" + product.destination_url) %>
<%= link_to "More Info", product_path(product) %>
然后,为了确保chrome浏览器中显示的x帧,我添加了以下内容
在chrome中启用x-frame
config.action_dispatch.default_headers = { 'X-Frame-Options' => 'ALLOWALL' }
您可能希望在某些页面上运行SSL,这可以通过下面链接的SSL enforcer gem轻松完成
ssl执行器
祝你在iFrame的丑陋之处航行时好运 您是如何检查是否设置了@url的?我已经为open_url页面添加了调试转储。@url设置为nil,尽管url正在通过
config.action_dispatch.default_headers = { 'X-Frame-Options' => 'ALLOWALL' }