ruby on rails - Searching for Associations -
I am trying to print the factory BBB_A.
I have two models
- aaa has_many bbbs
- bbb belong_to aaa
aaas. Rb
Define factory grades Factory: Do After AAA (Build). AAA | Aaa.bbbs & lt; & Lt; Build (: BBB_A) aaa.bbbs & lt; & Lt; Factory (at the end of the end of Bibibi_ B)bbbs.rb
Factorigirkdifain Factory: BBB Factory: Bibibi_a and Factory: Bibibi_ B End End End Endaaa_spec.rb
require describe 'spec_helper' Aaa it "puts works" AAA = Faktrigrlksent (AAA) aaa.bbbs (: Bibibi_a) # this gives both Bibibi_a and Bibibi_bi AAA. The Shild_net Bi_anil and endconsole output
BBB 1 BBB finished in 2 0.11593 seconds Example 1, 0 failure seeds 44359 With randomwhat do i want
1 example ended in 0.11 billion seconds, random failure with seed 4435 9Why is it that both put BBB_A and BBB_b? How can I just print it bbb_a?
You have to replace what you have to do
Aaa.bbbs (: bbb_a) with puts aaa.bbbs.first aaa andor
puts aaa.bbbs [0]and
BBB model, Rail creates the basic example methods for you asaa #bbb andBBB # aaa . This method accepts 0 or 1 arguments. If you pass an argument to this method astrue , then the query is removed on the database to obtain the relevant records. And if you argue this method asfalse , it only raises the cached results of the query (the query provided was removed once for caching).Therefore, when you do
puts aaa.bbbs (: bbb_a)passed the value only Neither
true orfalse .
Comments
Post a Comment