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

JavaScript

Ajax, 'Requested?' error

I'm on the last lesson for the AJAX section of ruby, but I keep getting this error:

    test: #edit when logged in should get edit and return success.
     (UserFriendshipsControllerTest):ActionView::Template::Error: undefined method
     `requested?' for #<UserFriendshipDecorator:0x4b5f970>

Now I want to fix this error, but I can't find the requested? method it mentions, I've tried to use the find option to locate it in the userfriendshipcontroller, userfriendshipdecorator and their test counter parts.

Let me know what you think.

7 Answers

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Allan Evans try adding delegate_all to your UserFriendshipDecorator class.

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Allan Evans, can you push your code up to GitHub and send me the link and I'll take a look?

Alright it's up, my user name is aevans27, thanks.

Alright, I'll get it done tonight.

That did it thanks! Can you tell me why that worked?

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

The reason that "delegate_all" fixes the problems is because a Ruby class only knows what methods it has available to it in its own class. When you're using Draper, by saying "delegate_all", you ask the decorator to ask the model it's decorating for any methods it doesn't know how to execute.

YAY, JASON YOU ARE AMAZING :DDDDD fixed my problem.