has-many-through

has-many-through

文章 0 浏览 8

使用“has Many through”进行急切加载——我需要阿雷尔吗?

我有三个表:users、members、projects。中间是一个连接表,表达了其他两个表之间的多通关系;它有一些有趣的属性,包括 join_code 和 activated。 更…

万人眼中万个我 2024-12-05 12:28:46 5 0

has_many :通过在连接表中创建重复项

我创建了 3 个模型:User、City、UserCity。 用户类: class User < ActiveRecord::Base has_many :user_cities, :dependent => :destroy, :uniq => t…

雨的味道风的声音 2024-12-05 05:42:05 7 0

一对多通过添加连接模型实例

我的模型: class Test include DataMapper::Resource property :id, Serial property :name, String, :default => '' has n, :test_visits has n, :v…

白云不回头 2024-12-04 05:11:12 7 0

如何将记录添加到 has_many :通过rails中的关联

class Agents << ActiveRecord::Base belongs_to :customer belongs_to :house end class Customer << ActiveRecord::Base has_many :agents has_many…

你另情深 2024-12-03 00:07:42 6 0

PostgreSQL Rails has_many :through / collection_singular_ids / :order 问题

在迁移到heroku的过程中,只有当我使用PostgreSQL时才会出现奇怪的错误(在Mysql中工作正常) 当我执行@user.county_ids时,我收到以下错误: ActiveR…

如果没结果 2024-12-02 05:09:59 8 0

我应该如何让我的模型实例属于我的用户模型中的所有用户?

我有以下设置,我想确保我的品牌模型中的所有品牌都属于我的用户模型中的所有用户。我还想确保,一旦创建了一个品牌,它属于所有用户,它也将属于未来…

潇烟暮雨 2024-12-01 16:19:44 8 0

Rails - 使用 group_by 和 has_many :through 并尝试访问连接表属性

有关一些背景信息,请参阅我的问题:使用STI的Rails应用程序——提取这些记录的最简单方法? 我有一些模型通过使用第三个连接表的关系与has_many连接…

安静被遗忘 2024-12-01 11:13:39 5 0

Rails 标记:按出现次数查找标签

我的应用程序中有一个相当简单的标记模型。 Photo has_many :taggings Photo has_many :tags, :through => :taggings Tag has_many :taggings Tag has…

神回复 2024-11-30 23:29:40 6 0

has_many :through 和 :foreign_key

我的模型如下所示: class Post < ActiveRecord::Base has_many :aspect_visibilities, :as => :shareable, :primary_key => :guid, :foreign_key => …

怂人 2024-11-30 14:08:16 8 0

将命名范围与 has_many_through 一起使用

我有以下模型: class Board < ActiveRecord::Base has_many :users, :through => :participants do def manager where("participants.role = ?", "Ma…

何以心动 2024-11-30 12:56:25 8 0

如何使用多态类模拟 has_many :through

我明白为什么 ActiveRecord 不能支持多态类上的 has_many :through 。但我想模仿它的一些功能。考虑以下情况,其中连接表关联两个多态类: class Host…

故人爱我别走 2024-11-30 00:35:44 5 0

通过构建 has_many

我有两个型号。用户和帐户如下 class Account < ActiveRecord::Base has_many :manages has_many :users, :through => :manages end class User < Act…

穿透光 2024-11-29 08:47:30 7 0

基于标签等多对多关联的 RoR 搜索

我建立了一个包含几个不同模型的 RoR 数据库。每个“记录”都有许多标签,并且通过“cat_id”放入一个类别中。我已经构建了所有模型,但我需要过滤方…

尐偏执 2024-11-29 07:47:39 7 0

通过 has_many :through with :conditions 保存连接属性

我有一个如下所示的 Artist 模型: # app/models/artist.rb class Artist < ActiveRecord::Base # Relationships has_many :releases has_many :songs…

梦太阳 2024-11-29 01:21:48 7 0

has_one :通过 =>多种的

出席和凭证: belongs_to :event belongs_to :account 因此:出勤和凭证之间是 1 对 1 的关系。 有没有办法不用我想太多就能做到这一点? # attendmen…

手心的温暖 2024-11-28 18:37:47 6 0
更多

推荐作者

梦断已成空

文章 0 评论 0

瞎闹

文章 0 评论 0

寄意

文章 0 评论 0

似梦非梦

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文