I''ve been poking around rails and now I''m trying to work out possible problem scenarios. One thing I came across is when a directory is added to a URL you get a Application Error (Rails) rather than a 404. For example http://demo.hieraki.org/test/ versus http://demo.hieraki.org/test/test.html Is there some way around that?
On Sun, 2005-01-23 at 21:45 -0500, Paul wrote:> I''ve been poking around rails and now I''m trying to work out possible > problem scenarios. One thing I came across is when a directory is > added to a URL you get a Application Error (Rails) rather than a 404. > > For example > > http://demo.hieraki.org/test/ > > versus > > http://demo.hieraki.org/test/test.html > > Is there some way around that?You may have to do some tests within the .htaccess file to test for available files before allowing the rewrite rule that puts all requests into the dispatch app. Your application error instead of 404 is because the rewrite rule changed the URL to /dispatch.[rb|cgi|fcgi]?controller=test&action=test.html -- Steven Critchfield <critch-wQLwMjUOumVBDgjK7y7TUQ@public.gmane.org>
This is just up to your rewriting rules. I personally find it nicer to catch most things in the application since most of my apps send emails to me when exceptions happen. So if there is a bad link going on i know whats up really quickly. On Mon, 24 Jan 2005 00:20:39 -0600, Steven Critchfield <critch-wQLwMjUOumVBDgjK7y7TUQ@public.gmane.org> wrote:> On Sun, 2005-01-23 at 21:45 -0500, Paul wrote: > > I''ve been poking around rails and now I''m trying to work out possible > > problem scenarios. One thing I came across is when a directory is > > added to a URL you get a Application Error (Rails) rather than a 404. > > > > For example > > > > http://demo.hieraki.org/test/ > > > > versus > > > > http://demo.hieraki.org/test/test.html > > > > Is there some way around that? > > You may have to do some tests within the .htaccess file to test for > available files before allowing the rewrite rule that puts all requests > into the dispatch app. Your application error instead of 404 is because > the rewrite rule changed the URL to > /dispatch.[rb|cgi|fcgi]?controller=test&action=test.html > > -- > Steven Critchfield <critch-wQLwMjUOumVBDgjK7y7TUQ@public.gmane.org> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tobi http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog
Ok, So now I have apache responding to requests for a rails project (contact) on port 3000; DocumentRoot points down into the public directory for the app; but I get an error message from rails (403 Forbidden) the error log reads: [error] [client 192.168.1.37] Directory index forbidden by rule: /Library/WebServer/Documents/contact/public/ I''ve created models and controllers as apropriate (they mirror what I had created while running under WEBbrick), copied in the work from there (all file and class names are identical) and moved in the config/database.yml so it hooks to the proper database instance; where''ve I gone wrong? Thanks in advance! Cheers, Twitch
Hi,
I have recently started using Rails and am currently digging into it
as well as Ruby.
Now I was wondering how to best handle RecordNotFound errors with
showing a nice 404 page and still not writing too much code. I came up
with a method in the ApplicationController and calling that method
with a block.
The method looks like this:
def handle404(pagetitle)
begin
yield
rescue ActiveRecord::RecordNotFound
@page_title = pagetitle
render "layouts/error", 404
end
end
And I call it as follows:
handle404("Project not found") {
@project = Project.find(@params["id"])
@page_title = "Project: " + @project.title
}
See also my German explanation of this approach at
http://patrice.kaywa.ch/ruby_on_rails/fehler-behandlung_in_rails.html
Is this a practical way of doing this stuff? How do you generally do
this?
Patrice
--
the Holy Scriptures, which are able to make you wise for salvation
through faith in Christ Jesus. (2 Timothy 3:15)