Home arrow Ruby-on-Rails arrow Page 3 - Managing Database Files with Ruby on Rails
RUBY-ON-RAILS

Managing Database Files with Ruby on Rails


In this second part of a five-part series on databases and Ruby-on-Rails, you'll learn about filesystem storage, managing uploads in Rails, and more. It is excerpted from chapter four of the book Advanced Rails, written by Brad Ediger (O'Reilly; ISBN: 0596510322).Copyright © 2008 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

Author Info:
By: O'Reilly Media
Rating: 3 stars3 stars3 stars3 stars3 stars / 2
February 01, 2010
TABLE OF CONTENTS:
  1. · Managing Database Files with Ruby on Rails
  2. · Sending Data with X-Sendfile
  3. · Web server configuration
  4. · Managing Uploads in Rails

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Managing Database Files with Ruby on Rails - Web server configuration
(Page 3 of 4 )

Of course, the front end web server must be properly configured to recognize and process the X-Sendfile header. Mongrel does not support X-Sendfile, as it assumes you will proxy to it from a server more capable of serving static content.

If you are using Lighttpd, it has X-Sendfile support built in. For Lighttpd/FastCGI, just enable the
allow-x-send-file option in the server configuration:

  fastcgi.server = (
    ".fcgi" => (
      "localhost" => (
       
...
       
"allow-x-send-file" => "enable",
        ...
      
)
    )
  )

If you are using Apache 2, things are a little more complicated (although not by much). You have to install the mod_xsendfile module* into Apache. There are two configuration flags, both accepting on/off values, which can then be used to control X-Sendfile behavior:

XSendFile
   Determines whether the X-Sendfile header is
   processed at all.

XsendFileAllowAbove
   Determines whether that header can send files 
   above the path of the request. It defaults to off for 
   security reasons.

Both of these configuration options can be used in any configuration context, down to the .htaccess file (per-directory). Best practice dictates that you should only specify XSendFile on in the narrowest possible context. Having X-Sendfile unnecessarily enabled is a security risk, as it allows a server application to send any file that the web server can access to the client.

To my knowledge, there is no way to use X-Sendfile on Apache 1.3 at this time.

Serving Static Files

One advantage of filesystem storage is that as long as the file data doesn't need to be protected with access control or otherwise acted upon dynamically, you can leverage your static web servers to serve that data. By exporting the storage path via NFS (or a caching filesystem such as AFS to conserve bandwidth), you can share the application's files with the static servers on your content distribution network. This completely removes the load from the application servers and provides a more scalable solution.


blog comments powered by Disqus
RUBY-ON-RAILS ARTICLES

- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form
- Ruby on Rails Templates and Layouts
- Action Pack Controller Creation
- Writing an Action Pack Controller

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials