Fresh Rails 3.1 安装失败...未初始化常量 JSON::ParserError
我正在使用 RVM 并多次安装了 Rails 3.1.0,但一旦开始使用它,我就会一遍又一遍地遇到相同的错误。
从全新安装的 Rails 3.1.0 中,我执行以下操作:
rails new fishapp
cd fishapp
bundle install
rails g scaffold Fish name:string
bundle exec rake db:migrate
但每次我转到 http://localhost:3000/fish 我得到:
Showing /Users/me/code/rails31/fishapp/app/views/layouts/application.html.erb where line #6 raised:
uninitialized constant JSON::ParserError
(in /Users/me/code/rails31/fishapp/app/assets/javascripts/fish.js.coffee)
Extracted source (around line #6):
3: <head>
4: <title>Fishapp</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
9: <body>
我一定是在尝试安装 Rails 时损坏了某些东西或其他东西,因为我不明白为什么全新安装会失败。有什么想法吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最初我只是注释掉了第 6 行(这样我就可以继续工作)。
最终我需要 javascript,所以我不得不回到这个问题。我将上面的行注释掉,并在其正下方硬编码了这一行:
页面加载正常,所以我查看了页面的源代码,然后查看
...只是发现了类似的错误:
所以我决定加载一个Rails 控制台,看看我是否可以加载 JSON gem,但 iconv 出现错误:
同时加载生成的 Rails gem:
所以我四处搜索并发现了这个:
http://beginrescueend.com/packages/iconv/
按照这些说明操作,您的问题将会得到解决!根据记录,这些说明是:
我将保留我所采取的步骤,以防其他人在 Google 上搜索类似错误。
Initially I simply commented out line #6 (just so I could keep working).
Eventually I needed javascript, so I had to return to this issue. I kept the line above commented out, and just hard-coded this one immediately below it:
The page loaded fine, so I viewed the page's source, and looked at
... only to find a similar error:
So I decided to load a rails console and see if I could load the JSON gem, but got an error with iconv:
Meanwhile loading the rails gem produced:
So I searched around and found this:
http://beginrescueend.com/packages/iconv/
Follow those instructions, and your problem will be resolved! For the record, those instructions are:
I'm leaving the steps I took in case others search Google for similar errors.
您可以尝试执行其中一些操作,看看是否有帮助,
gem Coffee 脚本
。multi_json
。You could try to do some of these to see if it helps,
gem coffee script
there.multi_json
under activesupport.