0

このようなコントローラーメソッドがあります。(ホームコントローラー内)

def verify_email
 // some logic
 format.json { render json: {  message: message  } }
 format.js

end

以下のように remote true を使用して、このメソッドを呼び出すことができます。これはJSメソッドです。

<%= form_for(resource, as: resource_name, url: home_verify_email_path, html: { id: "signup-form" }, remote: true, data: { controller: "validations", validations_target: "form" }) do |f| %>

それがフォームなので、リモートtrueを使用でき、完全に正常に機能しています。しかし、コントローラーからこのメソッドを呼び出すにはどうすればよいですか (次のシナリオで remote true をどこでどのように使用できますか?)

 in applicatin_controller

def after_sign_in_path_for(resource)
    if user.email_verified?
       redirect_to dashboard_url
    else
      home_verify_email_path (how can i call this url as JS request here in this particular case, i mean where we can use remote true here ? )
    end
  end

誰かがこの問題で私を助けることができますか?

4

0 に答える 0