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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 4, 9:23 am, redhotberry <redhotbe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Feb 4, 2011 at 6:25 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Feb 4, 9:23 am, redhotberry <redhotbe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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. > > Right -- seems that even if you could do this, it would be fighting theRails 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.> Fred > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Pankowecki (rupert)
2011-Feb-05 08:35 UTC
Re: How to work with Database in routes? Rails 3
You could use http://edgeguides.rubyonrails.org/routing.html#advanced-constraints for that, but probably I wouldn''t go this way. Robert Pankowecki http://robert.pankowecki.pl -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.