某个controller
def test
@test='你好'
end
test.rhtml中
<%=@test%>
执行的时候报错,如果把中文改成hello,运行正常。
是不是rails在代码里面不直接出现中文?还是要设置什么?
请各位指教,多谢!
[b]问题补充:[/b]
感谢"温柔一刀",不过我没明白,怎么看文件编码?
[b]问题补充:[/b]
感谢‘笨笨狗’,以你的方法吧文件保存成utf-8编码,不过居然报这样的错误:
testchinese_controller.rb:5: syntax error, unexpected kEND, expecting $end
代码如下:
class TestchineseController < ApplicationController
def index
@testchinese='你好'
end
end
哪里end出问题了?失败