Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Rails implementation of a database-based file system Ask Question. Asked 8 years, 8 months ago.
Active 8 years, 7 months ago. Viewed 2k times. Improve this question. Nicu Tofan Nicu Tofan 12 12 silver badges 31 31 bronze badges. Do you just need to model the file system, or do you also need to store the file data in the database? I'm also storing the content in the database. Can't you just use your system's file system?
The implementation would be way easier, and I can't see much gain in using a database to simulate a file system. Maybe one can use Rails to see the underlying file system in the server where the final application will be stored, I did not investigate that in any deep. This is a valid comment for the question as it is posted I kept it general because I did not find general answers in my searches. In my particular case the data has relational connections that make sense to be implemented in a database, I think.
TNick, did you try to use core Directory and File classes for your task? I have the same problem with data storage, but my project has nearly 10 different file classes — gaussblurinc.
Show 2 more comments. Active Oldest Votes. Or do I need to look into something else? Improve this question. Joe Flynn 6, 6 6 gold badges 30 30 silver badges 43 43 bronze badges. Add a comment. Active Oldest Votes. Yeah, shouldn't be a problem. Improve this answer. Sign up or log in Sign up using Google.
Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. There are other ways to perform CRUD operations on databases--the most common way is to use a Data Definition Language like SQL--but Rails makes the whole business a lot easier and more extensible for reasons described in the entry on migrations. Since the model can perform CRUD operations on an entire table in the database, it should be given a description of every column in that table.
Again, thinking of Excel, if we had a table for a users in our system, we would want to think of each type of data we'd like to keep track of for individual users.
In the following example, I've used just a username and password. We wouldn't actually want to store unencrypted passwords in the database, but we'll leave that concept out for now. The simplest way to write a model class is to let Rails do it for you.
Rails contains a model generator, which you can use via your command line, as long as you're in a Rails app already.
0コメント