Im 누군가가 간단한 실수 일 가능성을 밝힐 수 있기를 희망합니다. 로컬 변수 _article.html.erb에있는 article을 _article.html.erb에 중첩 된 다른 부분으로 전달하려고합니다. 부분 코드가 _article.html.erb에있을 때 잘 동작합니다. 많은 변수 (지역 변수 포함)를 시도했지만 로컬 변수를 전달하지 못하는 것 같습니다.Rails 3에서 로컬 객체를 중첩 된 부분에 전달합니다.
<%= form_for current_user.favorites.find_by_article_id(article), :html => { :method => :delete, :class => 'unfavorite_form', }, :remote => true do |f| %>
<div><%= f.hidden_field :article_id %></div>
<%= image_submit_tag("vote-favorite-on.png", :alt => "Favorite", :id => "favorites_button", :title => "Remove from favorites") %>
<% end %>
오류
_article.html.erb
<% if current_user.favorited?(article) %>
<%= render :partial => 'unfavorite', :object => article %>
<% else %>
<%= render :partial => 'favorite', :object => article %>
<% end %>
_favorite.html.erb (좋아하고 싫어하는 모두가 더 많거나 적은 동일, 그래서 하나를 게시 한) 메시지는 다음과 같습니다 rendering에 대한
undefined local variable or method `article' for #<#<Class:0x491c2b0>:0x6727a58>
덕분에, 그 생각했다 나는 긍정적이었다. 나는 그것을 게시하기 전에 시험했다. –
예, 그런 경우 발생합니다.) – pschuegr