[英]how to pass same parameter multiple times in ruby
我在Ruby中有以下索引方法
def index
if params.key?(:item)
@items = Item.get_items.where(item: params[:item])
else
@items = Item.get_items
end
我正在使用郵遞員進行測試,如下所示
http://localhost:3000/items?item=some_item
怎樣才能兩次通過相同的參數?
例如
http://localhost:3000/items?item=some_item&item=other_item
編輯:添加視圖
index.json.jbuilder
json.array! @items, partial: ‘items/item’, as: :item
_item.json.jbuilder
json.something1 item.something1
json.item_layout do
json.template_key item.layout
json.merge! item.layout_config if item.layout_config.present?
end
json.something (item.item_details) do |item_detail|
json.partial! ‘item_details/item_detail’, item_detail: item_detail
end
您是說像數組? 試試這個
http://localhost:3000/items?item[]=some_item&item[]=other_item
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.