以下 Ruby 代码会导致编写额外的行,我正在尝试找出导致该行的原因。
我的红宝石代码:
File.delete(RAILS_ROOT + '/app/views/filer/' + @navn + ".html.erb")
filen = File.open(RAILS_ROOT + '/app/views/filer/' + @app.slug + ".html.erb", "a+")
filen.write("#{params[:app][:cod]}")
我检查了参数:
Content-Disposition: form-data; name="app[cod]" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da"> <head> <title>Ruby on Rails: Welcome aboard</title> <%= javascript_include_tag 'jquery' %>
但是在创建文件时会添加新行:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da">
<head> <title>Ruby on Rails: Welcome aboard</title>
<%= javascript_include_tag 'jquery' %>
什么时候应该:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da">
<head> <title>Ruby on Rails: Welcome aboard</title>
<%= javascript_include_tag 'jquery' %>
这是对 rails 检查的检查:
"cod"=>"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"DTD/xhtml1-strict.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"da\">\r\n<head>