当我在simple_form中使用wrapper_tag时,它在开发模式下工作正常,但是,当我将应用程序部署到heroku时,渲染结果是不同的。
我像这样使用wrapper_tag
:
<%- SimpleForm.wrapper_tag = :p -%>
注意生产中的结果:(:div代替:p)
<form accept-charset="UTF-8" action="/courses/1" class="simple_form edit_course" id="edit_course_1" method="post">
<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="_method" type="hidden" value="put" /><input name="authenticity_token" type="hidden" value="+qH0C/hOaatVnw+Jp2vysanyG5tSB6E6gayIGlJCYbo=" /></div>
<div class="input string optional"><label class="string optional" for="course_course_id"> Course ID</label><input class="string optional" id="course_course_id" maxlength="255" name="course[course_id]" size="50" type="text" value="" /></div>
<div class="input string required"><label class="string required" for="course_name"><abbr title="required">*</abbr> Title</label><input class="string required" id="course_name" maxlength="255" name="course[name]" required="required" size="50" type="text" value="This is my first course here at clouds!!" /></div>
<div class="input text required"><label class="text required block" for="course_description"><abbr title="required">*</abbr> Description</label><textarea class="text required" cols="42" id="course_description" maxlength="1000" name="course[description]" required="required" rows="3">Just to test, to see if precompiled assets for checkeditor is working .. </textarea></div>
<div class="input integer optional field_with_hint"><label class="integer optional" for="course_credits"> Credits</label><input class="numeric integer optional three_digits" id="course_credits" name="course[credits]" step="1" type="number" /><span class="hint">Fill zero to disable course credit</span></div>
<div class="input boolean optional"><input name="course[list_in_catalog]" type="hidden" value="0" /><input checked="checked" class="boolean optional" id="course_list_in_catalog" name="course[list_in_catalog]" type="checkbox" value="1" /><label class="boolean optional" for="course_list_in_catalog"> List in catalog</label></div>
<div class="input string optional"><label class="string optional" for="course_validation_code"> Validation code</label><input class="string optional" id="course_validation_code" maxlength="255" name="course[validation_code]" size="50" type="text" value="" /></div>
<div class="input boolean optional"><input name="course[sequential_chapter_access]" type="hidden" value="0" /><input checked="checked" class="boolean optional" id="course_sequential_chapter_access" name="course[sequential_chapter_access]" type="checkbox" value="1" /><label class="boolean optional" for="course_sequential_chapter_access"> Sequential chapter access</label></div>
</form>
在开发模式下工作正常:(标签:p使用)
<form accept-charset="UTF-8" action="/courses/13" class="simple_form course" id="edit_course_13" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="_method" type="hidden" value="put" /><input name="authenticity_token" type="hidden" value="eOi8hkGQ8eoZYwzIQBcBEB66ekI9kTTYztsyU+UKzmQ=" /></div>
<p class="input string optional"><label class="string optional" for="course_course_id"> Course ID</label><input class="string optional" id="course_course_id" maxlength="255" name="course[course_id]" size="50" type="text" value="" /></p>
<p class="input string required"><label class="string required" for="course_name"><abbr title="required">*</abbr> Title</label><input class="string required" id="course_name" maxlength="255" name="course[name]" required="required" size="50" type="text" value="كيف تكسب الآخرة؟" /></p>
<p class="input text required"><label class="text required block" for="course_description"><abbr title="required">*</abbr> Description</label><textarea class="text required" cols="42" id="course_description" maxlength="1000" name="course[description]" required="required" rows="3">This is so cool course</textarea></p>
<p class="input numeric integer optional"><label class="integer optional" for="course_credits"> Credits</label><input class="numeric integer optional three_digits" id="course_credits" name="course[credits]" step="1" type="number" value="3" /><span class="hint">Fill zero to disable course credit</span></p>
<p class="input boolean optional"><input name="course[list_in_catalog]" type="hidden" value="0" /><input checked="checked" class="boolean optional" id="course_list_in_catalog" name="course[list_in_catalog]" type="checkbox" value="1" /><label class="boolean optional" for="course_list_in_catalog"> List in catalog</label></p>
<p class="input string optional"><label class="string optional" for="course_validation_code"> Validation code</label><input class="string optional" id="course_validation_code" maxlength="255" name="course[validation_code]" size="50" type="text" value="" /></p>
<p class="input boolean optional"><input name="course[sequential_chapter_access]" type="hidden" value="0" /><input class="boolean optional" id="course_sequential_chapter_access" name="course[sequential_chapter_access]" type="checkbox" value="1" /><label class="boolean optional" for="course_sequential_chapter_access"> Sequential chapter access</label></p>
</form>
这里有什么我想念的吗?我该怎么检查?
答案 0 :(得分:1)
它可能与开发与生产中的类缓存有关。
如果您想全局更改wrapper_tag
,则应在simple_form
初始化程序中执行此操作。如果您想逐个字段地更改它,可以将wrapper_tag
选项传递给input
电话。