下次 @Saito 讲讲 vagrant 咋样.....
#18 楼 @night_song 这个 hack 太夸张了,还得重编 openssh ...我回头去找找基于 pam 的插件...
嗯。而且只要把整个应用的目录中会改变的部分给 nginx 的 user 授权即可....授权多了也不这么让人放心
@Saito 我瞄了一眼 grack....想把他放到 rails 里...先问问你有没有做过..免得重造轮子........
嗯,膜拜下 @Saito !! 学了好多 ruby 跟 git 相关的东西.....毕设更有信心了..
报名!!
诶呀..这本书 豆瓣购书单
显示..无货
身在杭州的表示支持~~~
明天有吗明天~~~
啊..那是不是说,只要在某个 model 里面没有写任何 attr_accessible
和 attr_protected
的时候就是默认都可以 mass-assign 呢?
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">
似乎这时候 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 啊什么的..咋回事呢
#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
到底咋样才能正确的添加中间表记录啊..
报名
好感动...好干净的权限.......今儿个国产的应用权限都乱申请的...出个干净的不容易啊。
看到了 如何高效利用 Github 这篇文章,里面提到了 Jekyll 觉得很有趣,于是开始学习 Ruby