...">

Can't get rails current_page? method of working with GET and POST

Given that I have the following routes defined in routes.rb

get "signup" => "users#new"
post "signup" => "users#create"

and the following condition in my erb view

<%if current_page?(login_path) or current_page?(signup_path)%>
        <p> NOW YOU'RE IN</p>
<% end %>

How can I get both the GET and POST path that will be recognized by the current page? Now that it is created in # #, the p tag is not displayed. I guess this is because the route is defined by / signup as receiving for # new users, and post is something else.

I tried the following but it does not work

<%if current_page?(login_path) or current_page?(signup_path) or current_page?(controller: "users", action: "create")%>
            <p> NOW YOU'RE IN</p>
    <% end %>

Edit: the reason I have a message is because if the registration form has an error, it is redirected back to the registration page, but this time for some reason the action is no longer new, but creates

+4
1

current_page? false POST.

:

, http://www.example.com/products POST .

current_page?(controller: 'product', action: 'index') 
# => false

:

if controller.controller_name == "users" && controller.action_name == "create"

if request.path == "/signup"
+10

All Articles