How to work with Database in routes? Rails 3

Hello. How to check presence of object in DB in routes? If object
exists in DB - rais app shows its page, if not - it redirects to 404.
I know that it’s possible to do all this logic in controller but i
would to know how to do it in routes.

On Feb 4, 9:23am, redhotberry [email protected] wrote:

Hello. How to check presence of object in DB in routes? If object
exists in DB - rais app shows its page, if not - it redirects to 404.
I know that it’s possible to do all this logic in controller but i
would to know how to do it in routes.

I don’t think you can. Routes map urls to controllers & actions -
that’s it.

Fred

On Fri, Feb 4, 2011 at 6:25 PM, Frederick C.
<[email protected]

wrote:

Right – seems that even if you could do this, it would be fighting the
Rails conventions. Not sure what you are really trying to achieve, but
if
your concern is to intercept something before getting into a controller
action you could do a before_filter in your ApplicationController and
place
this kind of logic there.

You could use

for that, but probably I wouldn’t go this way.

Robert Pankowecki