Comments (13)
I'm guessing there's no way to customize the Kansas message?
from toto.
Read above : )
from toto.
Fixed in nogweii/toto@32b4d9b
To use it, just add set :error_page lambda { |code| "lol you got an error (#{code})" }
to your config.ru
from toto.
Nice! But can it display a custom page instead?
from toto.
Not as easily as you may like, though you can use the go() method, so I think (this is just off the top of my head) go "/error/#{code}.html"
should work, if you want to use static pages.
Of course, you can use go
in any manner, redirecting to any (local) URL.
from toto.
I get the following when I try to use go "/error/404"
(which I can navigate to directly, so I know my page works):
NoMethodError at /2010/04/01/this-is-a-test4
undefined method 'go' for #<Toto::Config:0x10172a6f8>
from toto.
This is now official, and the setting is just called :error
For custom pages, you could probably just load the file with File.read("public/#{code}.html")
or something similar..
from toto.
How could we render the 404 page with existing layout?
from toto.
Try this (I'm using HAML):
set :error do |code|
::Haml::Engine.new(File.read("templates/pages/#{code}.haml"), :layout => 'layout', :format => :html5, :ugly => true).render("templates/layout")
end
from toto.
ariejan, how about using ERB?
from toto.
@samnang - I don't use ERB, but it could be something like this:
ERB.new(File.read("templates/pages/layout.rhtml")).result(File.read("templates/pages/#{code}.rhtml"))
from toto.
@ariejan, I got an error because I have to pass binding object to ERB#result method instead of string.
from toto.
The easiest way is to:
# ...
set :error, lambda {|code|
ERB.new(File.read("templates/pages/error-#{code}.rhtml")).result
}
# ...
from toto.
Related Issues (20)
- 404 Error with Phusion Passenger HOT 1
- HTML tags are ignored HOT 4
- RSS xml malformation on Heroku.
- Dorothy - read on link does not work from fresh clone HOT 2
- Invalid ATOM Xml using default builder HOT 2
- How to cache the page and at the same time offer dynamic redirects
- Access 'articles' from outside of index page
- not working on heroku cedar? HOT 10
- non-blog usage, custom URLs
- Respond to HEAD requests with 200, not 400 HOT 1
- Smart-mode of markdown not documented
- Unmaintained repository HOT 2
- Error with routing to more Info HOT 1
- Having a lot of trouble getting toto to work on heroku
- a issue using thin with toto HOT 4
- 304 Headers
- Update code on rubygems HOT 2
- Content-length error prevents page load and leads lint error
- In Ruby 2.7 basically the tainting mechanism, leads to stackoverflow
- This looks really interesting! - GitLab instead of Heroku?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from toto.