Custom error pages 404, 500 etc


(Priit Pärna) #1

Hey, I was going to develop custom error pages for my site running on push_type and figured out, I’m actually stuck inside of push_type gem to actually do it, what about adding a possibility to overrule rails default ones?

Thanks!

…
  render template: 'push_type/setup', layout: nil, status: 404
else
  raise ActiveRecord::RecordNotFound
end

(Ryan Heneise) #2

This is how I handle custom error pages. I put this in application_controller.rb:

rescue_from ActiveRecord::RecordNotFound, with: :page_not_found
private 
def page_not_found
  @node = PushType::Node.exposed.published.find_by_path '404'
  render *@node.template_args
end

Then create a root page with the slug “404”.