我想渲染一个模态形式,并能够在不同的地方渲染它;因此我希望能够更改在服务器端创建新反馈所需的order_id(我使用AJAX)。
但是,我的渲染部分不起作用。我收到以下错误:
undefined local variable or method `user_order_id' for #<#<Class:0x007fec6be26af8>:0x007fec6bf1b2d8>
任何想法?
index.html.erb
[...]
<%= render partial: 'feedback_modal', locals: {user_order_id: @user_last_order} %>
[...]
_feedback_modal.html.erb
<%= simple_form_for(@review, method: :post, url: review_path(current_user.id, user_order_id), remote: true) do |f| %>
<%= f.input :rating, collection: [1,2,3,4,5], prompt: "Rate this meal", class: "col-sm-3" %>
<%= f.label :comment, "Your comments" %>
<%= f.text_area :comment, class: "commentaire" %>
<%= f.button :submit ,"Send Feedback", class: "btn" %>
<% end %>
控制器:
[...]
@user_last_oder = Order.where(user_id: current_user.id, status: nil).last.id
[...]