Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.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
Ruby on rails 3 NOOB问题嵌套内容\标记轨道时出现问题_Ruby On Rails 3_Content Tag - Fatal编程技术网

Ruby on rails 3 NOOB问题嵌套内容\标记轨道时出现问题

Ruby on rails 3 NOOB问题嵌套内容\标记轨道时出现问题,ruby-on-rails-3,content-tag,Ruby On Rails 3,Content Tag,我认为有以下几点 <%= content_tag :p, :class => "title-choose" do %> Select image or <%=content_tag :div, :class =>"inputReplacement" do %> <%= form_for @upload, :remote => true, :html => { :mul

我认为有以下几点

<%= content_tag :p, :class => "title-choose" do %>
         Select image or 
            <%=content_tag :div, :class =>"inputReplacement" do %>
                <%= form_for @upload, :remote => true, :html => { :multipart => true, :method => :post, :id => 'uploadForm', :class => "hiddenInput", :size => 13 } do |f| %>
                    <%= f.file_field :photo %>
                <% end %>
                add image from your computer:
            <% end %>
        <% end%>
它将生成以下html:

<p class="title-choose"> Select image or </p>
<div class="inputReplacement">
<form id="uploadForm" class="hiddenInput" size="13" method="post" enctype="multipart/form-data" data-remote="true" action="/uploads" accept-charset="UTF-8">
<div style="margin:0;padding:0;display:inline">
<input id="upload_photo" type="file" name="upload[photo]">
</form>
add image from your computer:
</div>
<p></p>
这不是我想要的。我要把这张桌子包在纸里

有人知道如何使用content_标签吗

谢谢


Mitch

当我将视图代码粘贴到我的Rails 3.0.7应用程序视图index.html.erb中时-命名很重要,我正确嵌套了以下内容:

<p class="title-choose">
         Select image or 
            <div class="inputReplacement">
                <form accept-charset="UTF-8" action="/globalize/translations" class="hiddenInput" data-remote="true" enctype="multipart/form-data" id="uploadForm" method="post" size="13"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="f9/6FmfCO7ezrhaUMOp+d7xOti+6UcvgzQq7M5u9HFU=" /></div>
                    <input id="globalize_translation_photo" name="globalize_translation[photo]" type="file" />
</form>                add image from your computer:
</div></p>
只是不介意我的@upload对象不同


是的,你真的应该在s中嵌套标记,而不是相反。

为什么不直接做纯html或haml呢?另外,从语义上讲,p应该是div所包含的:关于p中的div,您是对的。我会纠正的。也许这就是问题所在。另外,请尝试不使用内容标记,因为它看起来像是在erb模板中。普通的html标记在那里工作。仅在中使用内容标记helpers@corroded:在erb模板中使用content_标记实际上是受鼓励的,而不是使用纯html。非常感谢Pewel,我将尝试更改格式,使p不在div中。实际上,我必须与前端人员交谈,因此我将接受您的建议。