Created
September 16, 2011 10:35
-
-
Save qichunren/1221805 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jruby 1.6.4或者ruby-1.9.2-p180 | |
| Rails 3.0.9 | |
| 问题描述: | |
| 在rails初始化中声明HOST_NAME为一个String,然后在控制器中有这样的代码: | |
| str = "## " + HOST_NAME + " ##" | |
| 启动程序的时候会出错(rails s): | |
| 然后我将上面的代码改一下子: | |
| host_name = HOST_NAME | |
| str = "## " + host_name + " ##" | |
| 就什么问题也没有了。或者这样也没有问题 | |
| str = ("#" * 15 +" " + HOST_NAME) + " " + "#" * 15 + " " | |
| JRuby下面的错误提示信息: | |
| SyntaxError (/home/qichunren/code/xxx/app/controllers/xxxs_controller.rb:23: syntax error, unexpected tUPLUS | |
| str = "## " + HOST_NAME + " ##" | |
| ^): | |
| ======= | |
| Ruby下面的错误提示信息: | |
| /home/qichunren/code/ntdeck/app/controllers/sensors_controller.rb:23: syntax error, unexpected tUPLUS, expecting keyword_do or '{' or '(' | |
| str = "## " + HOST_NAME + " ##" | |
| ^ | |
| 然后我自己离开Rails环境,在ruby脚本中进行测试,没有发现这个问题。 | |
| 我想这个问题应该与Rails对待常量的策略有关系,谁可以解释一下? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
菜鸟来学习的 :)
ruby-1.9.2在irb下测试没问题。 请问具体是放在那个文件的? 是config/application.rb吗