无法生成路由

发布于 2024-09-17 22:17:03 字数 392 浏览 3 评论 0原文

我有一个问题如下。

我的routes.rb 文件中有一个资源设置,如下所示

resources :users do
    resources :sub_transactions
end
resources :sub_transactions do
    collection do
        get :income
        get :expenditure
    end
end

现在我应该编写的正确路线是什么,以便我可以生成以下路线,

users/1/sub_transactions/income
users/1/sub_transactions/expenditure

其中收入和支出不是ID

i have a problem as following.

i have a resources setup in my routes.rb file as following

resources :users do
    resources :sub_transactions
end
resources :sub_transactions do
    collection do
        get :income
        get :expenditure
    end
end

Now what is the correct route that i should write so that i can generate the following routes

users/1/sub_transactions/income
users/1/sub_transactions/expenditure

where income and expenditure are not ids

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白云悠悠 2024-09-24 22:17:03

您是否尝试过将这些调用添加到嵌套的 sub_transactions 资源?就像:

resources :users do
  resources :sub_transactions do
    collection do 
      get :income
      get :expenditure
    end
  end
end

我目前无法进行测试,但这将是逻辑起点(我认为)。

Have you tried adding those calls to the nested sub_transactions resource? Like:

resources :users do
  resources :sub_transactions do
    collection do 
      get :income
      get :expenditure
    end
  end
end

I'm not in a position to test at the moment but that would be the logical starting point (I figure).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文