【问题标题】:Render path with params使用参数渲染路径
【发布时间】:2017-02-01 14:09:49
【问题描述】:

我有两个模型,Carousel 和 Item,它们的关系是多对多的。

在 routes.rb 中:

resources :carousels do
  resources :items
end

我正在尝试在我的轮播索引中以模式呈现带有枚举器参数(类型)的新项目模板。

渲染代码:

render new_carousel_item_path(caroulsel), type: "image"

但是我遇到了以下问题:

ActionView::MissingTemplate at /carousels
Missing partial carousels/1/items/_new with {:locale=>[:"pt-BR"], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :slim, :coffee]}

有什么想法吗?

【问题讨论】:

标签: ruby-on-rails ruby ruby-on-rails-4


【解决方案1】:

你可以使用这个表格

render template: "carousels/items/new", locals: {caroulsel: caroulsel, type: "image"}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-26
    • 2022-01-21
    • 2011-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-10
    相关资源
    最近更新 更多