我的模型摘要:用戶有許多約會。預約有很多預訂。預訂屬於預約。路由錯誤:將參數傳遞給控制器中的操作
我想鏈接到一個特定的視圖(稱爲「users_bookings」),該視圖列出了特定約會的所有預訂。這是我曾嘗試:
<% current_user.appointments.each do |appointment|%>
<%= link_to "view all bookings", users_bookings_appointment_booking_path(appointment)%>
<%end%>
這是我的錯誤:
undefined method `users_bookings_appointment_bookings'
附加信息:
路線:
resources :appointments do
resources :bookings do
get 'users_bookings', :on => :collection
end
end
登記控制器創建行動:
def create
@appointment = Appointment.find(params[:booking][:appointment_id])
@booking = @appointment.bookings.new(params[:booking])
登記控制器Users_bookings操作:
def users_bookings
@appointment = Appointment.find(params[:booking][:appointment_id])
@bookings = @appointment.bookings.all
end
Users_bookings查看:
<% @bookings.each do |booking| %>
<td><%= booking.appointment_date%></td>
<td><%= booking.start_time %></td>
<td><%= booking.end_time %></td>
<%end%>
謝謝。非常感謝幫助。 – Benamir