Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
陈若涵
@ruohanc
VIP
NO. 1454 / 2012-03-16

Alibaba-inc
杭州
33 Topics / 586 Replies
15 Followers
2 Following
44 Favorites
其实我是SA..正在学写代码...
GitHub Public Repos
  • ZhongHongHVAC 19

    Python driver for ZhongHong HVAC Controller

  • python_talk_2020 1

  • ruhoh_hosting_server 1

    Closed

  • wxcloudrun-django 0

  • home-assistant 0

    :house_with_garden: Open-source home automation platform running on Python 3

  • nextjs 0

  • aliyun-oss-python-sdk 0

    Aliyun OSS SDK for Python

  • cks_web 0

    给老爸写的简单网站

  • dotfiles 0

  • direnv 0

    Unclutter your .profile

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • [杭州][2012年04月24号] Ruby Tuesday 在大浪 at April 26, 2012

    下次 @Saito 讲讲 vagrant 咋样.....

  • [杭州][2012年04月24号] Ruby Tuesday 在大浪 at April 26, 2012

    #18 楼 @night_song 这个 hack 太夸张了,还得重编 openssh ...我回头去找找基于 pam 的插件...

  • 请问 nginx+rails3.2.1+ubuntu11.10 的最佳权限设置是什么呢? at April 26, 2012

    嗯。而且只要把整个应用的目录中会改变的部分给 nginx 的 user 授权即可....授权多了也不这么让人放心

  • You might have expected an instance of Array 的时候的屏蔽方法 at April 25, 2012

    #5 楼 @hooopo 也可以这样

    <% @c.try(:each_with_index) do |c, index| %>
      #do sth
    <% end %>
    
    
  • 哪位大哥知道 Mac 终端光标在单词之间移动的快键 at April 25, 2012

    #3 楼 @huacnlee 有的..看 emacs key binding 就行了,大概是 option+f 是前进一个单词,option+b 回退一个单词..,

    然后 iterm2 里面的设置要改

  • 终于能理解 Vim 为什么用了不太顺手的几个键位 at April 25, 2012

    #10 楼 @gangmax @LarryLv 其实 <c-c> 也行嘛.. 我觉得是要比 <c-[>顺手

  • [杭州][2012年04月24号] Ruby Tuesday 在大浪 at April 25, 2012

    #14 楼 @Saito -,-! soga..我去研究一下.....那是不是要像你昨天那样多开一个 rack 啊....能不能把他当做中间件放到应用里面啊..

  • [杭州][2012年04月24号] Ruby Tuesday 在大浪 at April 24, 2012

    @Saito 我瞄了一眼 grack....想把他放到 rails 里...先问问你有没有做过..免得重造轮子........

  • [杭州][2012年04月24号] Ruby Tuesday 在大浪 at April 24, 2012

    嗯,膜拜下 @Saito !! 学了好多 ruby 跟 git 相关的东西.....毕设更有信心了..

  • [北京] 招聘 rails 开发人员 at April 24, 2012

    #2 楼 @chucai 底线比较低....

  • [杭州][2012年04月24号] Ruby Tuesday 在大浪 at April 24, 2012

    #6 楼 @Saito 支持!! 最近就在学 gitlabhq...

  • [杭州][2012年04月24号] Ruby Tuesday 在大浪 at April 24, 2012

    报名!!

  • 一个提议 at April 24, 2012

    诶呀..这本书 豆瓣购书单 显示..无货

  • 一个提议 at April 24, 2012

    身在杭州的表示支持~~~

  • [杭州][2012年04月17号] Ruby Tuesday 在大浪 at April 23, 2012

    明天有吗明天~~~

  • Github 被 Hack 懶人包 at April 21, 2012

    啊..那是不是说,只要在某个 model 里面没有写任何 attr_accessible 和 attr_protected 的时候就是默认都可以 mass-assign 呢?

  • Model 中的 :through 和 :include 有啥区别? at April 21, 2012

    @tumayun @nouse @hisea 实验了下

    对于 :through

    s1 = Supplier.create
    r1 = Representative.create
    Account.create( :supplier_id => s1.id, :representative_id => r1.id)
    Supplier.first.representative
    
    
    >  Supplier Load (0.3ms)  SELECT "suppliers".* FROM "suppliers" LIMIT 1
    >  Representative Load (0.2ms)  SELECT "representatives".* FROM "representatives" INNER JOIN "accounts" ON "representatives"."id" = "accounts"."representative_id" WHERE "accounts"."supplier_id" = 1 LIMIT 1
    >  => #<Representative id: 1, name: "rep1", created_at: "2012-04-21 00:12:53", updated_at: "2012-04-21 00:12:53">
    
    

    对于 :include

    似乎这时候 Supplier 根本就不存在 representative 方法,必须绕圈来读取

    Supplier.first.account.representative
    
    
    >  Supplier Load (0.2ms)  SELECT "suppliers".* FROM "suppliers" LIMIT 1
    >  Account Load (0.2ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."supplier_id" = 1 LIMIT 1
    >  Representative Load (0.1ms)  SELECT "representatives".* FROM "representatives" WHERE "representatives"."id" IN (1)
    > => #<Representative id: 1, name: "rep1", created_at: "2012-04-21 00:12:53", updated_at: "2012-04-21 00:12:53"> 
    
    

    model 就是按照主贴内容写的,最后的 SQL 没有各位所说的 join 啊什么的..咋回事呢

  • 关于多对多,中间表的名称 at April 21, 2012

    #2 楼 @ichord 啊。我按照 ihower 的这篇文章做得,但是在中间表添加记录的时候出错

    s1 = Supplier.create
    r1 = Representative.create
    Account.new(:supplier => s1, :representative => r1)
    
    

    ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: supplier, representative

    目测是 model 里面没加 attr_accessible, 但是加上

    attr_accessible :supplier, :representative
    
    

    之后就变成了

    ActiveRecord::AssociationTypeMismatch: Supplier(#70329520740200) expected, got Supplier(#70329532252340)

    大概是因为 model 里面没有这两个属性吧?model 里面应该只有 :supplier_id 和 :representative_id

    到底咋样才能正确的添加中间表记录啊..

  • Ruby China T 恤第二期报名活动开始啦![已结束] at April 20, 2012

    报名

  • Ruby China Android 客户端预览版 at March 28, 2012

    好感动...好干净的权限.......今儿个国产的应用权限都乱申请的...出个干净的不容易啊。

  • :slug 有什么特别的含义吗? at March 21, 2012

    #4 楼 @lgn21st ....那少了一个 h 啊...他们不是一般叫 shlug 的

  • 各位是因为什么事件和原因接触到 Ruby at March 20, 2012

    看到了 如何高效利用 Github 这篇文章,里面提到了 Jekyll 觉得很有趣,于是开始学习 Ruby

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