当我试图禁止用户时,我收到此错误,希望您能帮助我,谢谢
/ users / 1 / banned的ActionController :: RoutingError
未初始化的常量UsersController
视图/管理/ index.html.erb
<% @users.each do |user| %>
<p>
<%= user.email %>
<%= link_to "ban user", banned_user_path(user) %>
</p>
<% end %>
的routes.rb
devise_for :users do
resources :users do
member do
get :banned
post :banned
end
end
end
控制器/ admin_controller.rb
def banned
@user = User.find(params[:id])
session[:return_to] ||= request.referer
@user.update_attributes(banned: true)
redirect_to session.delete(:return_to)
end
答案 0 :(得分:1)
您似乎没有UsersController。创建一个UsersController并将banned
函数放在那里。您可以在命令行中使用rails g controller Users