0

我在这里检查了所有其他问题,但似乎找不到答案。我有

小路:

  1. attr_accessible :location, :total_time, :visits
  2. belongs_to :trackedsite, :touch => true

跟踪站点:

  1. attr_accessible :total_time, :url, :visits
  2. has_many :paths, :autosave => true

我想找到属于具有特定位置的 Trackedsite 的路径

我试过了:

@trackedsite = Trackedsite.find_by_url(params[:url_string])
@path = @trackedsite.find_by_location(params[:path_string])

但是我得到“没有这样的列:paths.trackedsite_id”(这是正确的,该列不存在,我应该在迁移中添加一些东西吗?)

4

1 回答 1

0

关联通过具有外键来工作。如果您的路径belongs_toaTrackedSite按照惯例需要有 a trackedsite_id,否则实体之间没有链接。

于 2013-02-22T23:01:51.913 回答