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 Build a Simple Ruby on Rails Application Customizing Forms Navigation Links

Razvan Cranganu
Razvan Cranganu
1,467 Points

Logout problems

Hi guys,

I have a problem un method: :delete. I doesn`t work for me. Any advices?

3 Answers

Razvan Cranganu
Razvan Cranganu
1,467 Points

Hy guys, it was the first time when I was posting to this forum. I was following the steps in the treebook app and the link for logout wasn't working for me.

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

the error was that it didn't supported the GET method. After some research I found out that I could change the method from delete to get e.g.:

config.sign_out_via = :get

located in the config/initializers/devise.rb and after that everything worked perfect.

Jack McDowell
Jack McDowell
37,797 Points

This is probably not the best solution given that you shouldn't sign out via GET, but... it works. Just change :delete on line~204 in the config/initializers/devise.rb file to :get.

Hi Razvan,

The best way to receive an answer to your question is to specify exactly what the problem is. Your question is too vague and generalized to receive any appropriate advice. Could you further clarify the problem you are having exactly? Maybe include the code in your question that is giving you trouble.

David Gross
David Gross
19,443 Points

Make sure that the url path ( example in the ruby code below is: todo_list ) is linking to the correct path of whatever you want to deleted . You need to tell ruby exactly what you want deleted. Also understand that the view page is talking to your controllers page. Make sure you have the destroy method in your todo_list controller controller.

 <li><%= link_to 'Destroy',  todo_list,  method: :delete, data: { confirm: 'Are you sure?' } %></li>Ā¬
 def destroy 
    @todo_list.destroy
 end