所以,我想将这段代码添加到设计注册控制器中。
当我打电话给@user.save
时。就在那之前,我需要打电话,@user.uid = SecureRandom.hex(whatever-value)
。
但是,我不想改变创建操作当前的运行方式。我只想添加@user.id = SecureRandom.hex
行。
那么,原始设计如何创建动作外观?
答案 0 :(得分:1)
def create
build_resource(sign_up_params)
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_up(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
expire_session_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
respond_with resource
end
end
更多文档: