McEntity.joins(:member_credit_scores).includes(member_credit_ent_profile: :entity).where('sf.accountx.namex like ?', "% Time%").first
以上是我的疑问。我期待的是
mc_entity = {
entity_sf_account_id: '0014PRD000fkeejAAA',
license_date: Date.today, portfolio_type_id: @portfolio_type.id,
technology_description: "some technology_description", is_rejected: false, credit_value_rating_type_id: @credit_rating_type.id,
member_credit_scores: {
"0" => {
avoided_expense: 151515, likelihood_of_assertion: 15, avoided_expense_notes: "some expense notes",
likelihood_notes: "some likelihood notes", is_approved: true
},
"1" => {
avoided_expense: 303030, likelihood_of_assertion: 30, avoided_expense_notes: "some random expense notes",
likelihood_notes: "some random likelihood notes", is_approved: false
}
}
}
但我得到的是没有任何关系数据的McEntity。
mc_entity = {
entity_sf_account_id: '0014PRD000fkeejAAA',
license_date: Date.today, portfolio_type_id: @portfolio_type.id,
technology_description: "some technology_description", is_rejected: false, credit_value_rating_type_id: @credit_rating_type.id,
}
答案 0 :(得分:1)
实际上正在拉取数据,如果你调用#member_credit_scores
方法它将返回数据而不进行查询,如果你想要它在json中,那么你可以将它作为参数传递
entity.to_json(methods: member_credit_scores)
这将调用该方法并将其添加到json对象。