English 中文(简体)
添加“连接”参数
原标题:Add querystring parameters to link_to

我很难增加调试参数,把_与乌尔埃尔珀连接起来。 例如,我有一个指数观点,即,在分类、过滤和想象方面,有统一要素(通过将产生)。 • 原始粉碎物能够正确管理页内固定的阻断参数。

是否有自动机制在指定路线上添加询问参数,或者我是否需要人工这样做? 对这一似乎简单的构造进行了大量研究,使我无能为力。

<><>Edit>/strong>

一些挑战:

  1. 如果我有两个问题参数,即桶子和amp子;分类,如何在连接——同时保持对方的当前价值时,确定其中一种特定价值? 例如:

    <%= link_to "0", profiles_path(:bucket =>  0 , :sorting=>?? ) %>
    
  2. 如果我有多种问题参数、桶子和amp;分类和安放;页数,我想确定其中之一的价值,是否有办法自动包括剩余参数的名称和价值? 例如:

    <%= link_to "0", profiles_path(:bucket =>  0 , [include sorting and page_size name/values here] ) %>
    
  3. • 原始粉碎板自动管理其页数变数和其他热点变量。 在管理页数方面,似乎没有自动识别要素。 虽然我看到了制定特定页数清单的代码,但我会为此拥有一个要素(如SO)。 部分挑战与第2号有关,一部分涉及根据现有/不存在记录隐藏/how取该调查要素。 另一种方式是,如果有记录可上页,我只想列入页数链接。 此外,我更希望自动列入其他QS变量(即页、桶、分类),而不是按名称列入链接。

最佳回答
问题回答

如果你想要保持现有的布局,不暴露于圣经学会的攻击,那就能够清理布道,只剩下贵方可以发送的灯塔:

# inline
<%= link_to  Link , params.slice(:sort).merge(per_page: 20) %>

翻译为中文:

如果你在多个地方使用,则清理控制器中的碎片:

# your_controller.rb
@params = params.slice(:sort, :per_page)

# view
<%= link_to  Link , @params.merge(per_page: 20) %>

如果你想通过一个集团,就象以下那样:

<%= link_to my_url, class: "stuff" do %>
  <i class="glyphicon glyphicon-inbox></i> Nice glyph-button
<% end %>

之后,可以通过下列途径完成:

<%= link_to url_for(params.merge(my_params: "value")), class: "stuff" do %>
  <i class="glyphicon glyphicon-inbox></i> Nice glyph-button
<% end %>




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签