1
這是我的.erb文件;Ruby on Rails將參數傳遞給partials
<% 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>
我得到的錯誤是;
未定義的方法`reviewer_rating」的#TipComment:0x007f8b38e29328>
我如何通過在reviewer_note.rating
?
除此之外,我會改變'current_user.type == ...'來user.reviewer?並在用戶模型中添加一個實例方法。 – Mohamad
閱讀[locals](http://guides.rubyonrails.org/layouts_and_rendering.html#passing-local-variables) –