1

^[[1;31m./app/views/sources/_form.html.erb:136 - 用局部变量替换实例变量^[[0m ^[[1;31m./app/views/sources/_form.html。 erb:138 - 用局部变量替换实例变量^[[0m

这到底是什么意思?消除此警告的程序是什么?

<div id="book-container">
<label class="control-label" style="width: auto; font-weight:bold;">"selected books<span class="
red-star"> *</span></label>
<div "book-container">
<% if @chapter.nil? %>
<%= select_tag('book_ids',
options_for_select(@books.collect { |s| [s.name, s.id, {title: s.name}] }, params[:book_ids]),
{multiple: true, prompt: "hello:", style: "width: auto;",
data: {'multiselect-opts' => {height: '400px'}}}) %>
<% else %>
<% selected_books = @chapter.get_selected_books %>
<%= select_tag('book_ids',
options_for_select(@books.collect { |s| [s.name, s.id, {title: s.name}] }, selected_books),
{multiple: true, prompt: "Hello", style: "width: auto;",
data: {'multiselect-opts' => {height: '400px'}}}) %>
<% end %>
4

1 回答 1

4

如果您尝试在部分中使用此代码,请尝试将@placements,@sites和其他实例变量作为局部变量传递。

因此,当您渲染局部时,请执行以下操作:

<%= render :partial => "form", :locals => { :placement => @placement, :sites => @sites } %>

然后代替 using @placementplacement在您的部分中使用,依此类推。目的是使局部更可重用。希望这可以帮助!!

于 2013-09-30T05:52:11.503 回答