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

(Help) Delete the params[:status] hash if it exists in the params hash.

Hello, I am currently learning RubyOnRails and I am not that experienced with programming. The headline is one of the "Code Challenge: More Parameter Modification" tasks and I just don't know what I am missing.

my answer so far: params[:status].delete(:user_id) if params[:status].has_key?(:user_id) and params[:status].delete(:status) if params[:status].has_key?(:status)

Would be grateful for a solution, everything else worked out fine so far :-)

5 Answers

params.delete(:status) if params[:status]

Thanks! I was also struggling with this one.

That code can also be changed to...

if params[:status]
    params.delete(:status)
end

to make it a bit easier to read

:D I was also doing this except the end keyword at the end

I was stuck because I didn't use the () or [] appropriately. Where is some information on how they are different and what they mean?