-1

这些是我的路线:

resources :auctions do
  resources :bids
end

我有auctions#show一个投标表格的观点:

= form_for [@auction, @bid] do |form|
  = form.input :maximum
  = form.button :submit

这当然POSTauctions/:auction_id/bids

我有这个bids#create动作:

def create
  #...some_logic...
  if @bid.save
    #...happy_face...
  else
    # See Below
  end
end

在这个“如果出价没有保存逻辑”中,我有:

render 'auctions/show'

这应该(并且确实)尝试渲染,app/views/auctions/show.html.erb但我收到此错误:

Missing partial bids/info-panel, application/info-panel with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:
    * "app/views"
    * "gems/devise-2.0.4/app/views"

显然这是一个问题!它正在寻找app/views/bids而不是寻找app/views/auctions部分。

我如何使上下文成为app/views/auctions那些部分?

4

2 回答 2

1

这样的事情应该这样做:

<%= render :partial => "auctions/info-panel" %>

如果不包括前导目录,则假定为当前目录。

于 2012-05-13T22:31:58.367 回答
1

既然这是一个错误条件,为什么不重定向到拍卖/展示动作而不是渲染它的模板。您可以通过重定向传递错误元数据,以便拍卖/显示操作知道其错误状态并相应地呈现表单。

于 2012-05-14T03:40:55.450 回答