Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
Link
@liuhui1226
Member
NO. 32927 / 2017-09-14

[email protected]
0 Topics / 4 Replies
0 Followers
0 Following
5 Favorites
GitHub Public Repos
More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • Ruby 数组转 hash at January 20, 2019

    h = Hash[*a.flatten] 这种方式如果遇到

    [ ['apple', 1], ['banana', 2], [['orange','seedless'], 3] ]
    

    就会报错,还是用下面这种方法吧:

    Hash[a3.map {|key, value| [key, value]}]
    

    https://codeday.me/bug/20170605/23146.html

  • 请问有哪位能讲讲 inverse_of? at September 25, 2017

    给像我这样的新手提个醒吧,Rails4.1 之后就不用手动写 inverse_of 了,不过为了配合其他功能,比如 accepts_nested_attributes_for,还是手动加上保险一点。

    如果你想学习学习,自己瞎搞搞,可以加上 inverse_of: false 试试,或者看看这篇文章https://ruby-china.org/topics/24998

  • 只要六步,轻松添加 Google 两步认证 at September 16, 2017

    🐂

关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English