我需要獲取選定訂單的配置文件(打印訂單)。從控制器滑軌外的模型獲取數據
我的profiles
表有一個user_id
列和我的prints
表也有一個user_id
列。
該Profile
和Print
模型belongs_to :user
模型。
打印模式:
class Print < ActiveRecord::Base
attr_accessible :comment, :document
belongs_to :user
end
和剖面模型:
class Profile < ActiveRecord::Base
attr_accessible :address, :name, :phone
belongs_to :user
has_many :prints
end
如何根據用戶從打印配置文件獲得數據?
什麼是您的用戶模型是什麼樣子?用戶是否有多個配置文件或只有一個? – Mischa
由於您在配置文件中擁有'has_many:prints',您不應該在Print上擁有'belongs_to:profile'嗎? – depa
打印和配置文件都屬於用戶。如果配置文件是打印 –