model-associations

    0熱度

    2回答

    我有以下兩種型號: class TopicContent < ActiveRecord::Base unloadable belongs_to :topic end 和 class Topic < ActiveRecord::Base unloadable has_one :topic_content accepts_nested_attributes_for :topic_con

    2熱度

    2回答

    我正在使用ElasticSearch在我的應用程序中進行搜索。 我們需要做的一件事就是有一種方法來存儲不同ElasticSearch類型之間的任意關係。 假設我們在ElasticSearch指數三種類型,如 「客戶」, 「生活」 和 「MovieGenres」。 比方說用戶想多生活方式爲客戶聯繫起來,會發生什麼情況是用戶指定的應用程序映射和內ElasticSearch採取「客戶」的的docId ,

    2熱度

    1回答

    我試圖在兩個模型之間創建一個has_one關聯。 class User < ActiveRecord::Base has_one :emergency_contact end class EmergencyContact < ActiveRecord::Base belongs_to :user end 當我嘗試通過鐵軌控制檯多個條目將保存爲單個用戶緊急聯繫人模型來

    0熱度

    3回答

    我陷入了一個小問題,但對於我試圖弄清楚我做錯了什麼已經很久了。我的場景是我有一個現有的模型user,現在我創建了另一個名爲`user_comment'的模型。 用戶模式: class User < ActiveRecord::Base has_many :user_comments end USER_COMMENT型號: class UserComment < ActiveRecord::

    0熱度

    1回答

    請幫 我有兩個表: hospitals id | name | adress | main_doctor_id doctors id | name | contacts | bio | hospital_id 在車型: hospital.rb has_many :doctors doctor.rb belongs_to :hospital 但我在一個需要更多的關聯 - 每個

    0熱度

    1回答

    我有三個型號:問題,用戶和Qrecord。 A Qrecord存儲了用戶已回答問題正確(在列中:已回答)和上次回覆時間(在列中:last_answered)多少次。 所以,一個問題has_many Qrecords和一個用戶has_many Qrecords。 Qrecord belongs_to:用戶和:問題。 Qrecord型號 id :integer not null, primar

    0熱度

    1回答

    我前幾天就知道了! discussion有很多discussion_replies和許多replies通過discussion_replies discussion_replies belongs_to的discussion和belongs_to的reply reply的has_many discussion_replies和許多discussions通過discussion_replies 現在

    -1熱度

    1回答

    我試圖找到外科醫生和約會之間的關係。 2.0.0-p195 :001 > surgeon = Surgeon.first Surgeon Load (0.1ms) SELECT "surgeons".* FROM "surgeons" ORDER BY "surgeons"."id" ASC LIMIT 1 => #<Surgeon id: 5, name: "Micheal Gorb

    2熱度

    3回答

    有兩種模式:折扣和時間折扣。 折扣has_one TimeDiscount和TimeDiscount belongs_to折扣。 我需要得到所有TimeDiscounts與關聯Discount.is_enabled等於true。我該怎麼做?我知道關於範圍,我可以做類似於這件事: scope :new_orders, -> { where(order_status: OrderStatus.new_

    0熱度

    1回答

    我想在我的rails應用程序中創建一個新頁面,您可以在登錄後訪問該頁面。您只需看到現有用戶的下拉菜單和下拉菜單使用提交按鈕將角色添加到該用戶的user_role列的角色。難道我這樣做了 rails g controller add_roles new create 或 rails g scaffold add_roles 我如何得到它提交正確的信息給用戶的表?