Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Building Social Features in Ruby on Rails Adding State Test Factories

Andrew Johnson
PLUS
Andrew Johnson
Courses Plus Student 12,617 Points

"I'll just copy and paste" Index.html.erb

I may have missed something, but this is the second time I've run into this issue. During the videos, Jason opts to skip over the front-end code for the rails app ( I'm on "Test Factories in Building Social Features in Ruby on Rails" ) and instead just copies and pastes all of the html/erb from an unknown source, leaving me totally in the dust. Is there a code sample in the video description I'm missing, or are we supposed to be retyping the code by pausing the video?

2 Answers

"I'll just copy and paste...." has always been one of my gripes during the lessons, especially when there's no link on the video page to the project files. In this case, it's not all that much code, so I paused and wrote it by hand. You could also go into a future video and find the project files with this file. In case you haven't yet done either of these, here's the code Jason copied and pasted.

FactoryGirl.define do
  factory :user do
    first_name 'First'
    last_name 'Last'
    sequence(:email) {|n| "user#{n}@example.com"}
    sequence(:profile_name) {|n| "user#{n}"}

    password "mypassword"
    password_confirmation "mypassword"
  end

  factory :user_friendship do
    association :user, factory: :user
    association :friend, factory: :user

    factory :pending_user_friendship do
        state 'pending'
    end

    factory :requested_user_friendship do
        state 'requested'
    end

    factory :accepted_user_friendship do
        state 'accepted'
    end
  end
end
Andrew Johnson
Andrew Johnson
Courses Plus Student 12,617 Points

Oh my, I completely forgot about the project files. I think this one is solved, haha. Thanks for the code!

Nelly Lam
Nelly Lam
5,098 Points

P-project files?.... I've been pausing and typing this whole time! Relieved but also resentful. I don't think it's good practice to be just copying and pasting everything. Especially when you're supposed to be teaching someone each step of the way.

Thanks for the reminder though. Just downloaded the files ... as I finish my last video.