Ruby on Rails Friday, July 28, 2017

How should the loop look like?

5 times do...

???

On Fri, Jul 28, 2017 at 5:59 PM, Colin Law <clanlaw@gmail.com> wrote:
On 28 July 2017 at 01:10,  <k.stulgys@gmail.com> wrote:
> I want to populate data between 2 models (blog title and comment body). In
> my example "5.times do..." I'm populating fake data only for my comment
> model. How do I populate for both?

Create the blog with its title and add the comments to the blog. If
you want separate blogs for each comment then put that inside the loop
so you create five blogs and comments.

Colin

>
> On Friday, July 28, 2017 at 1:48:49 AM UTC+10, Hassan Schroeder wrote:
>>
>> On Wed, Jul 26, 2017 at 11:15 PM,  <k.st...@gmail.com> wrote:
>>
>> > then seed.rb:
>> >
>> > 5.times do
>> >   comment.create([{
>> >     name: Faker::jadajada
>> >     body: Faker::jadajada
>> > }])
>> >
>> > but how do I include blog title as well?
>>
>> What exactly are you trying to accomplish? "include" where?
>>
>> --
>> Hassan Schroeder ------------------------ hassan.s...@gmail.com
>> twitter: @hassan
>> Consulting Availability : Silicon Valley or remote
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/5339c5e1-df60-4026-9157-73c28b28ccca%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/9bpSWyqujtM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuDtRkvedUEM9XGrKbHHKefQuTF2fMB59ynT5HMa8MJew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAFNzrsedh4%3D-_CGFW8O1D%3DbFu01xjvFWUSiVOTVfwJgovoVeZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment