我有一个单一的嵌套资源,如下所示:
map.resources :bookings, :member => { :rate => :post } do |booking|
booking.resource :review
end
给我这些路线:
new_booking_review GET /bookings/:booking_id/review/new(.:format) {:controller=>"reviews", :action=>"new"}
edit_booking_review GET /bookings/:booking_id/review/edit(.:format) {:controller=>"reviews", :action=>"edit"}
booking_review GET /bookings/:booking_id/review(.:format) {:controller=>"reviews", :action=>"show"}
PUT /bookings/:booking_id/review(.:format) {:controller=>"reviews", :action=>"update"}
DELETE /bookings/:booking_id/review(.:format) {:controller=>"reviews", :action=>"destroy"}
POST /bookings/:booking_id/review(.:format) {:controller=>"reviews", :action=>"create"}
我试过这个:
<% form_for [@booking, @review] do |f| %>
返回此错误:
undefined method `booking_reviews_path' for #<ActionView::Base:0x10572b888>
使用我的评论控制器
def new
@review = Review.new
@booking = Booking.find(params[:booking_id])
end
但这是有效的...如果我明确列出 URL...
<% form_for :review, :url => booking_review_path(@booking) do |f| %>
这不是什么大问题......但我想知道我做错了什么。
Thanks