Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 用局部变量替换实例变量_Javascript_Html_Ruby On Rails_Ruby_Ruby On Rails 3 - Fatal编程技术网

Javascript 用局部变量替换实例变量

Javascript 用局部变量替换实例变量,javascript,html,ruby-on-rails,ruby,ruby-on-rails-3,Javascript,Html,Ruby On Rails,Ruby,Ruby On Rails 3,^[[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:bol

^[[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 %>

“精选书籍*
{高度:'400px'}}})%>
{高度:'400px'}}})%>

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

因此,在渲染局部对象时,请执行以下操作:

“表单”,:locals=>{:placement=>@placement,:sites=>@sites}%>

然后,不要使用
@placement
,而是在您的部分中使用
placement
,依此类推。 其目的是使partials更加可重用。
希望这有帮助!!

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

因此,在渲染局部对象时,请执行以下操作:

“表单”,:locals=>{:placement=>@placement,:sites=>@sites}%>

然后,不要使用
@placement
,而是在您的部分中使用
placement
,依此类推。 其目的是使partials更加可重用。
希望这有帮助!!

您能向我们展示生成此错误消息的模板的代码吗?使用rails最佳实践获取这些消息。您仍然需要向我们展示上面错误消息中列出的模板的代码。添加了第136行和第138行的代码。/app/views/ad\u sources/\u form.html。erb:47看起来像第一个实例错误的代码也在第47行-你需要告诉我哪一行是136:)你能告诉我们生成此错误消息的模板的代码吗?使用rails最佳实践获得这些消息。你仍然需要向我们显示上面错误消息中列出的模板的代码。已经添加了第136行和第138行的代码。/app/views/ad_ces/_form.html.erb:47看起来这个bug的第一个实例也在第47行-你需要告诉我哪一行是136:)136:138:options_for_select(@books.collect{s |[s.name,s.id,{title:s.name}),params[:book_id]),{multiple:true,prompt:“hello:”,style:“width:auto;“这是136和138的代码:)136:138:options_for_select(@books.collect{s|[s.name,s.id,{title:s.name}}},params[:book_id]),{multiple:true,提示符:“hello:,style:“width:auto;”这是136和138的代码:)