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

A future error in a lessons

I was following a tutorial and I was getting an error using the suggested:

<%= link_to "Log Out", destroy_user_session_path, :method :delete %>

After Googling someone suggested using the following instead:

<%= link_to "Log Out", destroy_user_session_path, :method => :delete %>

This worked. Can someone explain why and if it's correct for future errors, please?

Thanks guys

1 Answer

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey craig crossland! The reason is that in the first example, the syntax is invalid. It should read:

<%= link_to "Log Out", destroy_user_session_path, method: :delete %>

By putting the colon on the other side of the "method" key, it automatically converts method: :delete in to a hash key:

{ :method => :delete }

Which is the same thing as in the second example. With the colon before the method key, Ruby thinks you mean that whole thing as a symbol, which is invalid syntax. Hope that helps!