Frage

I am upgrading a app to rails 3.0, from rails 2.3, I upgraded the clearance gem (gem 'clearance', '1.0.0.rc2') and it seems that sign_out needs to be method delete.

I updated my sign out to be:

<%= link_to 'SignOut', sign_out_path, :method => "delete" %><

Which translates into:

<a href="/logout" data-method="delete" rel="nofollow">Logout</a>

But when I look at the server log, it says:

Started GET "/sign_out?timeout=true" for 127.0.0.1 at 2012-10-03 20:28:38 -0400
User Load '44c84e19c75fa993029ca68b4f32019d2a56ab22' LIMIT 1
ActionController::RoutingError (No route matches "/sign_out"):

Rake routes shows:

sign_out DELETE /sign_out(.:format) {:action=>"destroy", :controller=>"clearance/sessions"}

Any ideas what could be wrong?

On a related note, I have a auto logout after 3 hours that will not work either, I dont know how to do method = delete from javascript...?

function logout()
{
  location.href='/sign_out?timeout=true';
}

<% if current_user != nil %>
// 3 hours of inactivity log them out
var t= setTimeout("logout()",10800000);
<% end %>
War es hilfreich?

Lösung

Ok, I found the answer, in rails 3, even the delete javascript comes from an external source. The person setting up our rails 3 setup did not include prototype or jquery, so nothing was acting on this. Configuring https://github.com/rails/jquery-ujs should do the trick!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top