我有一个自定义注册控制器,但我不想覆盖设计中的创建操作。当我尝试注册用户时,我收到此错误:
Unknown action
The action 'create' could not be found for Devise::RegistrationsController
是因为我有一个自定义注册控制器而要求它吗?如果是这样,这是否意味着我需要从这里复制我没有覆盖的所有操作:https ://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb
还是因为我的申请有问题?
我的路线:
devise_for :user, :controllers => { :registrations => "devise/registrations" }, :skip => [:sessions] do
get 'signup' => 'devise/registrations#new', :as => :new_user_registration
post 'signup' => 'devise/registrations#create', :as => :user_registration
end
这是我的设计注册控制器
class Devise::RegistrationsController < DeviseController
skip_before_filter :require_no_authentication
def edit
@user = User.find(current_user.id)
@profile = Profile.new
end
def update
# required for settings form to submit when password is left blank
if params[:user][:password].blank? && params[:user][:password_confirmation].blank?
params[:user].delete(:password)
params[:user].delete(:password_confirmation)
end
@user = User.find(current_user.id)
if @user.update_attributes(params[:user])
set_flash_message :notice, :updated
# Sign in the user bypassing validation in case his password changed
sign_in @user, :bypass => true
redirect_to after_update_path_for(@user)
else
render "edit"
end
end
protected
def after_update_path_for(resource)
user_path(resource)
end
def after_sign_up_path_for(resource)
user_path(resource)
end
end
这是注册表:
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
...
<div>
<%= button_tag :type => :submit, :class => "btn btn-large btn-inverse" do %>
Sign up
<% end %>
</div>
...
<% end %>