デバイスの動作をカスタマイズしようとすると、デバイスがどのように機能するかを理解するのに苦労しています。
SocietyとCollaboratorの2 つの異なるモデルを処理する必要があり、登録フォームは両方の同じビューにある必要があります。
したがって、両方のモデルを処理する新しいコントローラーを作成して、 「devise registration controller create method」をオーバーライドする必要があります。
そして、ここに痛みが来ます。
ここから「別のコントローラー内の Devise フォーム」とhereから、devise を機能させるには、これらの新しいヘルパーを定義する必要があることがわかります。
module ContentHelper
def resource_name
:user
end
def resource
@resource ||= User.new
end
def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end
end
そして、オーバーライドしたい create メソッドは次のとおりです。
def create
build_resource
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_in(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
終わり
ワーデンの機能を損なうことなく機能させる方法がわかりません。(build_resource)。なにか提案を?性感染症を使わずに解決策を見つけることはできません!