Reputation: 1861
These are my routes:
resources :auctions do
resources :bids
end
I have the auctions#show
view with a form for bids:
= form_for [@auction, @bid] do |form|
= form.input :maximum
= form.button :submit
This of course POST
to auctions/:auction_id/bids
.
I have this bids#create
action:
def create
#...some_logic...
if @bid.save
#...happy_face...
else
# See Below
end
end
In this "if the bid didn't save logic" I have:
render 'auctions/show'
This should (and does) try to render the app/views/auctions/show.html.erb
but I get this error:
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"
Obviously this is a problem!
It's looking in app/views/bids
instead of app/views/auctions
for the partials.
How do I make the context be app/views/auctions
for those partials?
Upvotes: -1
Views: 125
Reputation: 8463
Since this is an error condition, why dont you redirect to auctions/show action instead of rendering its template. You can pass error metadata with your redirect, so that auctions/show action knows that its an error state and renders the form accordingly.
Upvotes: 1
Reputation: 6120
Something like this should do it:
<%= render :partial => "auctions/info-panel" %>
If you don't include the leading directory, it assumes the current directory.
Upvotes: 1