Rails,通过参数获取引擎控制器操作的URL

4

我有两个独立的引擎 OfferPrices

我该如何通过带有参数的哈希值,从Offers引擎视图获取到Prices引擎控制器的URL?

#config/routes.rb
Rails.application.routes.draw do
  mount Offers::Engine, at: "offers", as: "offers_routes"
  mount Prices::Engine, at: "prices", as: "prices_routes"
end

#offers/offers_controller.rb
class Offers::OffersController
  def show
  end
end

#prices/prices_controller.rb
class Prices::PricesController
  def index
  end
end

#views/offers/show.html.slim
= link_to "Prices", { action:"index", controller:"prices/prices" }

在这种情况下,link_to 会引发错误:
*** ActionController::RoutingError Exception: No route matches {:controller=>"prices/prices"}

我知道offers_routes.offers_path助手,但在我的情况下,我应该使用带参数的哈希表。

1个回答

3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接