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
Allan Evans
9,501 PointsAjax, '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
Treehouse Guest TeacherHey Allan Evans try adding delegate_all to your UserFriendshipDecorator class.
Jason Seifer
Treehouse Guest TeacherHey Allan Evans, can you push your code up to GitHub and send me the link and I'll take a look?
Allan Evans
9,501 PointsAlright it's up, my user name is aevans27, thanks.
Allan Evans
9,501 PointsAlright, I'll get it done tonight.
Allan Evans
9,501 PointsThat did it thanks! Can you tell me why that worked?
Jason Seifer
Treehouse Guest TeacherThe 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.
Arthur Cast
3,619 PointsYAY, JASON YOU ARE AMAZING :DDDDD fixed my problem.