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
Riley Hilliard
Courses Plus Student 17,771 PointsBuilding Social Features in Ruby on Rails: More Parameter Modification
I've been stuck on this questions for about 2 weeks now and have tried pretty much everything that would seem to make sense to me. The question is: Delete the params :status hash if it exists in the params hash.
It would make sense that they are looking for the code from the lesson which is:
if params[:status] && params[:status].has_key?(:user_id)
params[:status].delete(:user_id)
end
however that does not delete the status param, so I tried everything from:
if params[:status].has_key?(:user_id)
params[:status].delete(:status)
end
to
if params[:status].has_key?(:status)
params[:status].delete(:status)
end
to
if params[:status].has_key?(:user_id)
params[:status].delete(:user_id && :status)
end
Basically I have tried everything I can think of, looked everywhere for a similar issue, and have no idea how to get around this question. Has anyone else had trouble with it?
6 Answers
Riley Hilliard
Courses Plus Student 17,771 PointsI was over thinking it. (seems to usually be my problem, hah.)
if params.has_key?(:status)
params.delete(:status)
end
ecp
838 Pointsoxanaox
16,295 Pointsif params[:status].has_key?(:user_id) params[:status].delete(:user_id) end
Jason Seifer
Treehouse Guest TeacherYou're getting really close, Riley! The part of the hash you're trying to delete is one level up from what you've tried so far. The question is slightly different than what's in the videos.
Jason Seifer
Treehouse Guest TeacherYou got it :)
Jennifer Fry
9,855 PointsApologies for being dense, but I also had the same issue above. I entered Riley's answer above as well as
if params.has_key?(:status) params.delete(:user_id) end
and neither seems to work. Am I missing something here?