小编por*_*pop的帖子

自我指导has_many:通过自定义:主键问题

我试图在我的Rails 2.3.8应用程序(ruby 1.8.7)中模拟twitter模型

class Connection < ActiveRecord::Base
  belongs_to :subject, :foreign_key => 'subject_id', :primary_key => 'user_id', :class_name => 'User'
  belongs_to :follower, :foreign_key => 'follower_id', :primary_key => 'user_id', :class_name => 'User'
end

class User < ActiveRecord::Base
  has_many :relations_to, :primary_key => 'user_id', :foreign_key => 'follower_id', :class_name => 'Connection'
  has_many :relations_from, :primary_key => 'user_id', :foreign_key => 'subject_id', :class_name => 'Connection'
  has_many :linked_from, :through => :relations_from, :source => :subject, :primary_key => 'user_id'
  has_many :linked_to, :through => :relations_to, :source => :follower, :primary_key => 'user_id'
end
Run Code Online (Sandbox Code Playgroud)

当我执行User.first.linked_from时,这给了我一个"SystemStackError:stack …

ruby activerecord database-design ruby-on-rails

5
推荐指数
1
解决办法
1881
查看次数

Google Chrome扩展程序从源添加iframe

我正在尝试在iframe中加载myframe.html并将该iframe附加到当前页面的DOM中.如果myframe.html是我的扩展源的一部分,这可能吗?

我在想类似的东西

var iframe = document.createElement("iframe");
iframe.setAttribute("src", "myframe.html"); //what would be my path here, if this were possible?
document.body.appendChild(iframe);
Run Code Online (Sandbox Code Playgroud)

google-chrome-extension

1
推荐指数
1
解决办法
2498
查看次数