这是我的.erb文件;
<% if @comment.reviewer_notes && current_user.type == "User::Reviewer"%>
<% @comment.reviewer_notes.each do |reviewer_note| %>
<?= reviewer_note.rating %> <-- this "works" ie prints out rating on screen
<%= render 'partials/comments/form' %>
这是我的.erb部分;
<div class="admin-rating stars clear">
<%= reviewer_note.rating %> <-- this does not work.
</div>
我得到的错误是;
#TipComment的未定义方法`reviewer_rating':0x007f8b38e29328&gt;
如何传递reviewer_note.rating
?
答案 0 :(得分:2)
您应该将其作为变量传递给Partial。
<%= render 'partials/comments/form', note_rating: reviewer_note.rating %>
答案 1 :(得分:2)
<%= render partial: 'reviewer_note_rating', locals: {reviewer_note: reviewer_note} %>