has-one

    0熱度

    1回答

    我有幾個型號ScoreScoreAuthorityScoreColor和ScoreType。得分has_one權威,顏色和類型。管理局,顏色,並輸入每個belong_to得分。我無法爲Score創建表單。 我希望用戶根據分數創建這種關係,並且每個人似乎只處理從權限,顏色,類型表單創建的相反場景。我的意思是專門爲例子: Authorities - foo - bar Colors - re

    0熱度

    1回答

    我對Laravel有一個小問題。我完全瞭解它,並試圖爲我擁有的某些內容創建一個multilang模型。 這是我的配置: 數據庫: 表Appartements酒店: 1個ID INT(10) 2地址VARCHAR(255) 3郵編INT(11) 4城市VARCHAR(255 ) 5國家VARCHAR(255) 6 created_at時間戳 7的updated_at時間戳 表appartement_

    3熱度

    3回答

    所以我的問題是這樣的: https://gist.github.com/panSarin/4a221a0923927115584a 當我保存這個形式我得到錯誤,如在標題 NoMethodError (undefined method `updated?' for #ActiveRecord::Associations::HasOneAssociation:0x00000008fcacf8>):

    0熱度

    1回答

    我有兩種模式:附表和項目。計劃belongs_To項目和項目has_one計劃。有幾個問題,但我認爲他們都有同樣的原因。下面是時間表#代碼創建控制器: def create @schedule = Schedule.new(schedule_params) @schedule.project = Project.find(params[:project_id])

    1熱度

    1回答

    我has_one關聯有問題。 在我的用戶模型,我已經定義: has_one :category 在user_form是: = f.select: category, options_for_select(Category.all.collect{|c|[c.name, c.id]}, @user.category), prompt: 'choose' 如果我想要的,但它顯示在指數: use

    0熱度

    1回答

    我有一個用戶和團隊模型。用戶只能有一個團隊,每個團隊都屬於一個用戶。我正努力讓協會能夠雙向工作。 組隊模式: class Team < ActiveRecord::Base belongs_to :user end 用戶模式: class User < ActiveRecord::Base has_one :team end 我添加了一個TEAM_ID列到用戶表的u

    0熱度

    1回答

    您好我有has_one關聯工作select_box的問題。 我有模型image_element這是多態: class ImageElement < ActiveRecord::Base belongs_to :imageable, polymorphic: true belongs_to :image end 模型圖像: has_one :image_element, a

    0熱度

    1回答

    因此,這裏有我的模型: user.rb: has_one :interview_slot interview_slot.rb:belongs_to :user 的interview_slot有start_time,一個end_time和available布爾值。 舉例來說,我已經生成了一個20 interview_slot實例的列表,我想要做的就是讓我的用戶從下拉框中選擇其中的一個。 我先檢查用戶

    0熱度

    3回答

    我在用戶模型中具有以下關係。 has_many :subscriptions, dependent: :destroy has_one :subscription, -> { where 'end_date >= ?', Date.today } :訂閱實質上是他們最新的每月訂閱。 :訂閱是他們以前每月訂閱的一個數組(包括最新的)。他們列出了start_date,end_date,user_

    0熱度

    1回答

    我有一對一的用戶和配置文件模型。 以下是設備創建的User模型的代碼。 class User < ActiveRecord::Base has_one :profile , dependent: :destroy end 代碼Profile模型。 class Profile < ActiveRecord::Base belongs_to :user end 現在我有