Skip to content

How to return a template when some rodauth pages return 404 code #229

Closed Answered by janko
Halvanhelv asked this question in Q&A
Discussion options

You must be logged in to vote

Rodauth::Rails::App is a Roda subclass, so yes, Roda plugins can normally be used with rodauth-rails. You could write something like this:

# 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 #rails_render method for more flexibility:

  plugin :not_found do
    # renders "app/views/shared/not_found" page
    rodauth.send(:rails_render, template: "shared/not_found")
  end

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Halvanhelv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants