Hi, I want to implement logic in Rail so that I can count number of views to an image served by my server. Any suggestions on how to do it ? How do I intercept request to an image , perform book keeping, then redirect the request to the image ? Thanks! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> I want to implement logic in Rail so that I can count number of views > to an image served by my server. Any suggestions on how to do it ? > > How do I intercept request to an image , perform book keeping, then > redirect the request to the image ?Images should route straight thru your web server without ever touching Rails - or especially Ruby! Ask this question on a forum that covers your web server. Reading its access.log to see which images are popular might be efficient, or might not! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well actually i need to do more than counting the views. I need to log information about the client and perform some tasks before serving the image. I need to also do several database transactions. Actually I can make the problem simple. The request can come to my regular rails function. Thus, any request which comes to http://myserver.com/controller/test should direct request to http://myserver.com/images/my_precious.jpg How do I do that ? Thanks On Jun 7, 5:37 pm, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I want to implement logic in Rail so that I can count number of views > > to an image served by my server. Any suggestions on how to do it ? > > > How do I intercept request to an image , perform book keeping, then > > redirect the request to the image ? > > Images should route straight thru your web server without ever touching Rails - > or especially Ruby! > > Ask this question on a forum that covers your web server. Reading its access.log > to see which images are popular might be efficient, or might not!--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 8 Jun 2008, at 10:08, procyon wrote:> > Well actually i need to do more than counting the views. I need to log > information about the client and perform some tasks before serving the > image. I need to also do several database transactions. > > Actually I can make the problem simple. The request can come to my > regular rails function. Thus, any request which comes to > http://myserver.com/controller/test should direct request to > http://myserver.com/images/my_precious.jpg > > How do I do that ? >send_data, send_file, xsendfile Fred> Thanks > > On Jun 7, 5:37 pm, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> I want to implement logic in Rail so that I can count number of >>> views >>> to an image served by my server. Any suggestions on how to do it ? >> >>> How do I intercept request to an image , perform book keeping, then >>> redirect the request to the image ? >> >> Images should route straight thru your web server without ever >> touching Rails - >> or especially Ruby! >> >> Ask this question on a forum that covers your web server. Reading >> its access.log >> to see which images are popular might be efficient, or might not! > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
How about something like: def my_action # some db transactions and other tasks redirect_to ''/images/my_image.jpg'' end then put the image in /public/images/my_image.jpg This will prevent rails from having to serve the image (which isn''t terribly efficient). The only problem is that anyone who directly visits ''http://www.example.com/images/my_image.jpg'' will see the image and all your db transactions and other tasks will be skipped. I hope that helps, Paul On Jun 8, 2:08 am, procyon <kunal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Well actually i need to do more than counting the views. I need to log > information about the client and perform some tasks before serving the > image. I need to also do several database transactions. > > Actually I can make the problem simple. The request can come to my > regular rails function. Thus, any request which comes tohttp://myserver.com/controller/testshould direct request tohttp://myserver.com/images/my_precious.jpg > > How do I do that ? > > Thanks > > On Jun 7, 5:37 pm, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I want to implement logic in Rail so that I can count number of views > > > to an image served by my server. Any suggestions on how to do it ? > > > > How do I intercept request to an image , perform book keeping, then > > > redirect the request to the image ? > > > Images should route straight thru your web server without ever touching Rails - > > or especially Ruby! > > > Ask this question on a forum that covers your web server. Reading its access.log > > to see which images are popular might be efficient, or might not!--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---