Ruby on rails Rails-重定向以显示传递参数的页面
我想从我的Ruby on rails Rails-重定向以显示传递参数的页面,ruby-on-rails,Ruby On Rails,我想从我的货币控制器重定向到我的市场控制器,将当前货币作为参数传递(市场有许多货币)。我想这样做: redirect_to markets_show_url(id: @currency.market.id, currency: @currency) 如何正确执行此操作?在config/routes.rb中定义路由 比如说 get "markets/:id" => "markets#show", as: :markets_show 在控制器中调用 重定向\u至市场\u显示\u url
货币
控制器重定向到我的市场
控制器,将当前货币作为参数传递(市场有许多
货币)。我想这样做:
redirect_to markets_show_url(id: @currency.market.id, currency: @currency)
如何正确执行此操作?在config/routes.rb中定义路由 比如说
get "markets/:id" => "markets#show", as: :markets_show
在控制器中调用
重定向\u至市场\u显示\u url(id:@currency.market.id,currency:@currency.currency\u name)
Url将是
重定向到market\u url(@currency.market,currency\u id:@currency.id)
在市场的控制器中
:-
def show
@market = Market.find(params[:id])
@currency = Currency.find(params[:currency_id])
end
由于市场
有许多
货币,因此,对于当前货币
货币
id应作为参数传递,以在市场
控制器显示
操作中获取当前货币。对不起,实际上市场有许多
货币。我又编辑了一遍。在这种情况下我该怎么办?