在 Aptana3、RoR 中启动服务器时出现错误

发布于 2024-12-24 00:47:37 字数 626 浏览 1 评论 0原文

恐怕我有一个有点愚蠢的问题,但我自己无法解决这个问题:

alex@ALFA:~/Aptana Studio 3 Workspace/rails-test$ rails server
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/var/lib/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load': /home/alex/Aptana Studio 3 Workspace/rails-test/config/initializers/session_
store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: => '_rails-test_session'
                              ^

I'm afraid that I have a bit silly question, but I wasn't able to solve this problem myself:

alex@ALFA:~/Aptana Studio 3 Workspace/rails-test$ rails server
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/var/lib/gems/1.8/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load': /home/alex/Aptana Studio 3 Workspace/rails-test/config/initializers/session_
store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: => '_rails-test_session'
                              ^

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月静好 2024-12-31 00:47:37

键:=> “_rails-test_session” 不是有效的 Ruby。您可以执行 key =>; valuekey: value,但它们不能组合。

key: => '_rails-test_session' is not valid Ruby. You can either do key => value or key: value, but they can't be combined.

长梦不多时 2024-12-31 00:47:37

Ruby 哈希语法在 1.9 中进行了更新。您现在可以像这样创建哈希:

hash = {
  foo: "bar",
  faz: "baz"
}

但您仍然可以使用旧的“哈希火箭”样式:

hash = {
  :foo => "bar",
  :faz => "baz"
}

在两个实现中 foofaz 都是 符号

你的问题是 key: =>; '_rails-test_session' 是一个弗兰肯哈希,您正在尝试组合两种样式的哈希。使用 key::key =>

The Ruby hash syntax was updated in 1.9. You can now create hashes like this:

hash = {
  foo: "bar",
  faz: "baz"
}

But you can still use the old 'hash rocket' style:

hash = {
  :foo => "bar",
  :faz => "baz"
}

In both implementations foo and faz are symbols.

Your problem is that key: => '_rails-test_session' is a franken-hash, you're trying to combin both styles of hash. Either use key: or :key =>.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文