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

General Discussion

Adding States code challenge

Hey there. I'm on the Building Social Features in Rails > Managing Friendships > Adding States code challenge 2/2. The challenge is "Call the "block_mutual_friendship" method after the transition to the blocked state."

Right now, my code is

class UserFriendship < ActiveRecord::Base
  belongs_to :user
  belongs_to :friend, class_name: 'User', foreign_key: 'friend_id'

  state_machine :state, initial: :pending do
   after_transition on: :block, do :block_mutual_friendship
    state :requested
    state :blocked
  end
end

After reading forum posts from months ago, I see that you don't need the exclamation mark like in the video, but even though I don't have that, it still says I'm wrong somehow.

2 Answers

' or "

Ah ok. Where in the code would I put those? Around block_mutual_friendship?