我想计算这个块中的条目。由于 ruby 块变量范围,我不处理这个代码。有什么办法解决这个问题吗?
arr_showcase.each do |entry|
@entry = ContestEntry.find_by_id(entry)
if @entry.view_in_showcase == true
@entry.view_in_showcase = false
@entry.save
entry_added_showcase += 1
else
@entry.view_in_showcase = true
@entry.save
entry_removed_showcase += 1
end
end
redirect_to :back, :notice => "#{entry_added_showcase} Desings added, #{entry_removed_showcase} Designs removed."