我一直在試圖自定義設計註冊方法來註冊更多的參數,也更新更多(目前爲止沒有運氣),但我總是得到Unpermitted parameters:
錯誤。我試過使用這Adding extra registration fields with Devise和https://github.com/plataformatec/devise#strong-parameters,但我不能克服。添加自定義參數來設計註冊 - 未經允許的參數
我也想過創建一個新表來容納一個外鍵的用戶ID,並把它放在那裏像user_id, display_name, profile_picture
這樣的東西,但我會有同樣的問題,當試圖從同一頁提交的一切(混亂與設計控制器)。
你對我如何解決這個問題有任何建議嗎?還有什麼我必須發佈?
的routes.rb
devise_for :users, controllers: { registrations: 'users/registrations' }
用戶/ REGC
def create
build_resource(registration_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?
respond_with resource, :location => after_sign_up_path_for(resource)
end
else
clean_up_passwords
respond_with resource
end
end
private
def registration_paramss
params.require(:user).permit(:email, :display_name, :terms_of_services, :profile, :password, :password_confirmation)
end
請張貼你的設計配置。 – 31piy
@ 31piy更新了它 –
您使用的是什麼版本的設計?你能告訴我們重寫控制器(用戶/註冊)嗎?只需創建操作和您自定義註冊參數的部分即可。 – gkats