【问题标题】:Ransack and nested routingRansack 和嵌套路由
【发布时间】:2013-09-02 19:59:33
【问题描述】:

我有以下类型的资源路由:

resources :cities do
  resources :restaurants
end

这会产生以下类型的路由:

/restaurants/:city_id/

在我的餐厅索引控制器中,我有通常的洗劫代码,但是当我点击搜索按钮时,我被重定向到 /restaurants 而不是 /restaurants/:city_id。

如何调整 ransack 以便在提交搜索表单时重定向到 URL /restaurants/:city_id 而不是 /restaurants

谢谢!

【问题讨论】:

    标签: ruby-on-rails ransack


    【解决方案1】:

    你可以设置manuel url

    <%= search_form_for @q, url: city_restaurants_path(params[:city_id]) do |f| %>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-13
      • 2016-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-18
      • 2015-08-01
      • 1970-01-01
      相关资源
      最近更新 更多