我用Devise做授权。问题是注册新用户时出现错误
Routing Error No route matches [POST] "/users/sign_up"
我是 Rails 的新手,所以对此的任何帮助将不胜感激。
我的 routes.rb 看起来像这样:
Rails.application.routes.draw do
devise_for :users, :controllers => { :omniauth_callbacks => "callbacks" }
resources :posts
root 'posts#index', as: 'home'
root 'user_registration#new'
resources :posts do
resources :comments
end
get ':controller(/:action(/:id(.:format)))'
get 'about' => 'pages#about', as:'about'
post ':controller(/:action(/:id(.:format)))'
post ':controller(user_registration(/:action(/:id(.:format)))'
end
结果rake routes
new_user_password_path GET /users/password/new(.:format) devise/passwords#new
edit_user_password_path GET /users/password/edit(.:format) devise/passwords#edit
user_password_path PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
POST /users/password(.:format) devise/passwords#create
cancel_user_registration_path GET /users/cancel(.:format) devise/registrations#cancel
new_user_registration_path GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration_path GET /users/edit(.:format) devise/registrations#edit
user_registration_path PATCH /users(.:format) devise/registrations#update
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
POST /users(.:format) devise/registrations#create
new_user_confirmation_path GET /users/confirmation/new(.:format) devise/confirmations#new
user_confirmation_path GET /users/confirmation(.:format) devise/confirmations#show
POST /users/confirmation(.:format) devise/confirmations#create
太好了谢谢!有了这个我有点想通了,现在障碍在另一个。当你再次尝试发送@mail 时,那些“确认”出现错误的关于错误被获取)
ActionView::Template::Error (undefined method `error_notification' for #<Ac
tionView::Helpers::FormBuilder:0x000000000f140ca8>):
1: <h2>Resend confirmation instructions</h2>
2
3: <%= form_for(resource, as: resource_name, url: confirmation_path(res
ource_name), html: { method: :post }) do |f| %>
4: <%= f.error_notification %>
5: <%= f.full_error :confirmation_token %>
6:
7: <div class="form-inputs">
app/views/devise/confirmations/new.html.erb:4:in `block in _app_views_devis
e_confirmations_new_html_erb__768788303_126423300'
app/views/devise/confirmations/new.html.erb:3:in `_app_views_devise_confirm
ations_new_html_erb__768788303_126423300'
它在这条线上崩溃: <%= f.error_notification %>
error_notification
是一个 SimpleForm 方法,为了使其工作,form_for
必须将助手替换为simple_form_for
. 您需要在所有设备形式中执行此操作显然,您在设备之后安装了 SimpleForm。您可以删除所有设备视图并再次生成它们(如果您没有在那里进行任何特殊更改),那么 SimpleForm 将被自动拾取。这里有更多细节