associations

    0熱度

    1回答

    我的數據庫包含產品,商店和分支機構。一個分支屬於一個商店,一個商品屬於一個商店,但也可以選擇屬於一個分支。 問題:我如何(優雅地)從產品驗證所選分支是否實際上與爲產品選擇的商店相同? 我已經在使用像$rules->existsIn這樣的buildRules來驗證所選的Shops和Branches是否存在於第一位。我覺得我應該能夠推斷這些功能,所以這些也是交叉檢查。 注:我特別要求驗證。我意識到我可

    0熱度

    1回答

    每次向父對象添加子對象(has_many關聯)時,我都想運行before_save或after_add回調。在回調中,我想根據所有孩子(課程)的end_date屬性在父代(隊列)上設置end_date屬性。 class Cohort < ActiveRecord::Base has_many :courses before_save :update_end_date

    0熱度

    1回答

    我有一個用戶表,其列total_user_xp與has_many :goals關聯。 的目標表有其在模型計算用下面的方法列total_goal_xp: # goal.rb belongs_to :user has_many :goal_activities has_many :activities, through: :goal_activities def t

    0熱度

    1回答

    沿着接合的鋸齒ASSOCATION我有Posts和Users基本應用程序。我想,以確保用戶只提出對符合下列條件的職位: 他們以前沒有 看到這個帖子,他們是不是這個帖子的作者 要爲此,我有這些協會: User.hasMany(Post, { foreignKey: 'user_id' }); User.belongsToMany(Post, { as: { sin

    1熱度

    1回答

    我正在使用Rails和React。我有兩個型號:schedule和worker。 worker belongs_to schedule和schedule has_many workers。我想從反應中對rails進行更新請求。 這是fetch功能是什麼樣子,我用它來發送請求: function updateSchedule(scheduleId, date, message, workersArr

    1熱度

    1回答

    對於報告,我必須找到事務數據集的關聯規則。我下載了這組數據: http://archive.ics.uci.edu/ml/datasets/online+retail 然後,我刪除了一些列轉換爲名義值和標準化,然後 我得到這個:https://ufile.io/gz3do 所以我想我有一個數據與交易上設置我可以使用FP增長和Apriori,但我沒有得到任何規則。 它只是告訴我:沒有規則發現! 有人

    0熱度

    1回答

    我有一個問題,在我的簡單表單中向文章添加分類。 這些類別顯示在simple_form_for中,但category_id在創建時並不歸因於文章! (params?) Tx對你有幫助! 我已經創建了兩個模型 class Category < ApplicationRecord has_many :articles end class Article < ApplicationReco

    1熱度

    1回答

    我有幾個車型在在以下方面相關的軌道: 模式 class User < ApplicationRecord has_many :contracts has_many :properties, through: :contracts has_many :documents, through: :contracts class Contract < Applicatio

    4熱度

    1回答

    我在使用feathersjs。我已閱讀documentation。 如何執行此方法來檢查服務鉤羽毛鉤或告訴我另一種檢查方法。 const { disallow } = require('feathers-hooks-common'); function include() { return function (hook) { const productPrice = hoo

    -1熱度

    1回答

    我有兩個模型,我想在一個表中顯示它們。 模型1: class Name < ActiveRecord::Base has_one :employer, :foreign_key => 'application_id' end 模型2: class Employer < ActiveRecord::Base belongs_to :name, :foreign_key =>