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

creating mutual friendships

I'm learning rails and I need some help. I want to add a social feature to a website where users can add and remove friends. I've joined two models, FriendRequest and Friendship, which both have their own controller and restful routes. I have the correct associations in the model and the correct controller actions. My issue is creating the user interface for this feature. I added a button which as such, <td class="info"><%= link_to 'Add Friend', friend_request_path(:friend_id => user), :method => :post %></td> This sends the friend request. My controller code has an index action which collects the requests as such: def create friend = User.find(params[:friend_id]) @friend_request = current_user.friend_requests.new(friend: friend) if @friend_request.save render :show, status: :created, location: @friend_request else render json: @friend_request.errors, status: :unprocessable_entity end end def update @friend_request.accept head :no_content end def index @incoming = FriendRequest.where(friend: current_user) @outgoing = current_user.friend_requests end def destroy @friend_request.destroy head :no_content end How do i create a UI to view the requests that are sent and received? So the user should navigate to the index action of the friend_requests controller and see all "pending" requests and "received" requests. So far I can send requests but I don't know how to accept them or view the requests. Any insight greatly appreciated!!