我一直在windows中使用rails一段时间,并且我决定在最近在linux上尝试它。所以我一直在设置了一切,但现在我已经在Windows上创建的项目不会在Ubuntu上正常运行:失败来解读以下语法:rails语法“渲染json:@products”
render json: @products
产生以下错误:
/home/dcastro/workspace/teste/app/controllers/products_controller.rb:9: syntax error, unexpected ':', expecting '}'
format.json { render json: @products }
^
/home/dcastro/workspace/teste/app/controllers/products_controller.rb:20: syntax error, unexpected ':', expecting '}'
format.json { render json: @product }
且仅当我将其更改为工作原理:
render :json => @products
起初我还以为是因为我用红宝石的旧版本(即1.8.7)。所以我安装了1.9.2p290,但没有奏效。
如果很重要,我使用rails 3.1.0和ubuntu 11.04。
有谁知道是什么原因造成的?我该如何解决它?提前致谢!
你尝试过老语法'render:json => @products'吗? – Bohdan
我做了,我在我的帖子中指出。 – dcastro
我发现哪里出了什么问题:即使我安装了1.9.2,服务器正在1.8上运行。所以我卸载了ruby1.8,并为ruby1.9.2创建了一个名为“ruby1.8”的符号链接,欺骗服务器在ruby 1.9.2上运行。 – dcastro