我在我的应用程序上安装了devise并在我的application.html.erb文件中应用了以下内容:
<div id="user_nav">
<% if user_signed_in? %>
Signed in as <%= current_user.email %>. This cannot be cheese?
<%= link_to 'Sign out', destroy_user_session_path %>
<% else %>
<%= link_to 'Register', new_user_registration_path %> or <%= link_to 'Sign in', new_user_session_path %>
<% end %>
</div>
Run Code Online (Sandbox Code Playgroud)
我跑了rake routes并确认所有路线都有效.
另外,在我的routes.rb文件中我有devise_for :users和root :to => "home#index".
单击"注销"链接时出现以下路由错误:
No route matches "/users/sign_out"
Run Code Online (Sandbox Code Playgroud)
是什么导致错误?
我正在使用Rails 3,并且有一个页面可以输出数据库中的帖子列表.我希望能够从链接中删除帖子.
下面的第二个例子有效,但第一个没有.谁知道为什么第一个不起作用?我的观点包含:
# this link sends a "GET" request which asks for the #show function
<%= link_to 'Delete', post, :method => :delete %>
# this link sends the proper "DELETE" request which asks for the #destroy function
<%= button_to 'Delete', post, :method => :delete %>
Run Code Online (Sandbox Code Playgroud)
我的路线文件包含以下内容:
resources :posts
Run Code Online (Sandbox Code Playgroud)