I have a button that links to a controller like so:
# button in the view
button_to "Mark as complete", mark_complete_path
# controller
def mark_complete
# mark as complete...
end
I'd like the controller to redirect the user to the auth path under certain conditions. Something like the following:
def mark_complete
unless signed_in?
redirect_to "/auth/github"
end
end
But, because only POSTs are allowed against the auth path, and HTTP redirects don't allow POSTs, this doesn't work. Instead, it shows a No route matches [GET] "/auth/github".
Is there a way to authorize users through the controller?
I have a button that links to a controller like so:
I'd like the controller to redirect the user to the auth path under certain conditions. Something like the following:
But, because only
POST
s are allowed against the auth path, and HTTP redirects don't allowPOST
s, this doesn't work. Instead, it shows aNo route matches [GET] "/auth/github"
.Is there a way to authorize users through the controller?