How to return a template when some rodauth pages return 404 code #229
-
For example if I go directly to the /reset-password page it will return 404 and white screen but I would like to use my own 404 error template, how can I do that? I saw that Roda has a not_found plugin, can it be used with Rodauth-Rails or is there another solution? |
Beta Was this translation helpful? Give feedback.
Answered by
janko
Sep 11, 2023
Replies: 1 comment
-
# app/misc/rodauth_app.rb
class RodauthApp < Rodauth::Rails::App
configure RodauthMain
plugin :not_found do
# renders "app/views/rodauth/not_found" page
rodauth.render("not_found")
end
route do |r|
# ...
end
end You could also use plugin :not_found do
# renders "app/views/shared/not_found" page
rodauth.send(:rails_render, template: "shared/not_found")
end |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Halvanhelv
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rodauth::Rails::App
is aRoda
subclass, so yes, Roda plugins can normally be used with rodauth-rails. You could write something like this:You could also use
#rails_render
method for more flexibility: