how to call a rails controller method as js request, from application controller?

142 views Asked by At

I have a controller method like this. (in home controller)

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

end

I know that, we can call this method, by using remote true like below. as this is a JS method.

<%= 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| %>

as it is the form, I can use remote true, and it's working perfectly fine. but how can i call this method from the controller (like where and how can I use remote true in the following scenario?)

 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

can someone help me with this problem?

0

There are 0 answers