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
Kerel Lacy
8,474 PointsArgumentError in UserFriendshipsController#create
Not sure what I did wrong below is the error message I get:
wrong number of arguments (0 for 1) Rails.root: /Users/KerelLacy/Desktop/Projects/treebook
Application Trace | Framework Trace | Full Trace app/controllers/user_friendships_controller.rb:17:in `create' Request
Parameters:
{"utf8"=>"?", "authenticity_token"=>"bJeIta+DuGDtrMr99dr/TaA27PA4YkV0+2yB6DOHV1M=", "user_friendship"=>{"friend_id"=>"mikethefrog"}, "commit"=>"Yes, Add Friend"}
Here is my code from User_friendships_controller.rb https://gist.github.com/lacykerel/4956271
2 Answers
Jason Seifer
Treehouse Guest TeacherOn line 17, try changing this:
if params[:user_friendship] && params[:user_friendship].has_key?[:friend_id]
To this:
if params[:user_friendship] && params[:user_friendship].has_key?(:friend_id)
It's a small syntax error but it will prevent the action from working.
Kerel Lacy
8,474 PointsHi Jason, that worked thanks!