2011-03-28 147 views
0

我正在尝试将Rails 2.3.9应用升级到Rails 3,并且我一个接一个地面临问题。我为Rails 2.3.9使用了自动完成插件,它工作正常。但现在在Rails 3.0中,而不是显示文本框,它只是显示需要生成的html。这里是产生自动完成场升级到Rails 3.0

<table class="table_style"> 
<caption><b>Customer Details</b></caption> 
<tr> 
<td><label for="customer_investigator"><%= RB['investigator']%></label><label class="mandatory">*</label></td> 
<td><%= text_field_with_auto_complete "customer", :investigator, { :onblur=> "if(this.value=='') {this.value='last, first';this.style.color='#aaa';}",:onfocus=> "if(this.value=='last, first') {this.value='';this.style.color='#000';}"},{:skip_style => true, :url=>{:action=>'autocomplete_name'}, :with =>"'name='+element.value"} %></td> 
</tr> 
</table> 

现在,这是生成的html看起来像

"<input id="customer_investigator" name="customer[investigator]" onblur="if(this.value=='') {this.value='last, first';this.style.color='#aaa';}" onfocus="if(this.value=='last, first') {this.value='';this.style.color='#000';}" size="30" type="text" /><div class="auto_complete" id="customer_investigator_auto_complete"></div><script type="text/javascript"> 
//<![CDATA[ 
var customer_investigator_auto_completer = new Ajax.Autocompleter('customer_investigator', 'customer_investigator_auto_complete', '/accessions/autocomplete_name', {callback:function(element, value) { return 'name='+element.value }}) 
//]]> 
</script>" 

内容看起来好像没什么问题我的HTML代码。但生成的html以引号开头,因此而不是显示文本框,它只是在窗体上显示生成的html。它在Rails 2.3.9中工作得很好。有人可以帮忙吗?

感谢

回答

1

尝试的自动完成代码之前使用原料

<%= raw(text_field_with_auto_complete "customer", :investigator, { :onblur=> "if(this.value=='') {this.value='last, first';this.style.color='#aaa';}",:onfocus=> "if(this.value=='last, first') {this.value='';this.style.color='#000';}"},{:skip_style => true, :url=>{:action=>'autocomplete_name'}, :with =>"'name='+element.value"}) %> 
0

我总是使用rails_upgrade宝石从梁2我的应用程序升级到轨道3 https://github.com/jm/rails_upgrade

正如你一个接一个地说出你面临的问题,这个宝石可能可以帮助你在升级过程中。