# Location of ancillary files

**URL:** <https://www.ruby-forum.com/t/location-of-ancillary-files/139898>\
**Category:** Rails\
**Created:** [June 8, 2008, 8:18pm UTC](https://www.ruby-forum.com/t/location-of-ancillary-files/139898 "2008-06-08T20:18:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [June 8, 2008, 8:18pm UTC](https://www.ruby-forum.com/t/location-of-ancillary-files/139898/1 "2008-06-08T20:18:36Z")

</div>

Let’s say, for example, that I want to create an order form and that I  
want to assign an order number to each submitted order form for  
tracking purposes. So, I create a little file to store the latest  
number. Then when a new order comes in, I grab that number, increment  
it by one, assign the incremented number to the order, and finally  
replace the number that’s in the file with the new number. My  
question is this: Under the Rails conventions, where would be the  
appropriate place to locate the file that stores the number?

Thanks for any input.

```
  ... doug
```

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [June 8, 2008, 9:07pm UTC](https://www.ruby-forum.com/t/location-of-ancillary-files/139898/2 "2008-06-08T21:07:37Z")

</div>

Since “Rails is a full-stack framework for developing database-backed  
web applications…,” [1] the convention is to have an orders table  
with an auto-incremented id column. Of course, you could have another  
auto-incremented column, e.g., number (if that’s not a reserved word  
in Ruby/Rails), so that the id is kept meaningless in the domain.  
Thus, each order that you create will be assigned the next number.  
Since I _assume_ that you’re storing the orders in a database, why  
store the order number in a file?

[1] [http://rubyonrails.org/](http://rubyonrails.org/)

Regards,  
Craig

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [June 8, 2008, 11:14pm UTC](https://www.ruby-forum.com/t/location-of-ancillary-files/139898/3 "2008-06-08T23:14:05Z")

</div>

> Since I _assume_ that you’re storing the orders in a database, why  
> store the order number in a file?

Yep, you got the reason. I’m not using a database for this  
hypothetical task. I know I could do it that way. The thing is this.  
If (for whatever reason) I decide not to use a database and store the  
order number in a file, I’d like to know where under the Rails  
conventions, it would be appropriate to locate that file.

Thanks for the input.

```
  ... doug
```

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [June 8, 2008, 11:43pm UTC](https://www.ruby-forum.com/t/location-of-ancillary-files/139898/4 "2008-06-08T23:43:28Z")

</div>

On Jun 8, 10:13 pm, doug [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Since I _assume_ that you’re storing the orders in a database, why  
> > store the order number in a file?
> 
> Yep, you got the reason. I’m not using a database for this  
> hypothetical task. I know I could do it that way. The thing is this.  
> If (for whatever reason) I decide not to use a database and store the  
> order number in a file, I’d like to know where under the Rails  
> conventions, it would be appropriate to locate that file.

I don’t think rails has a strong opinion since the convention would be  
to put it in the db 🙂

Fred

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [June 9, 2008, 12:38am UTC](https://www.ruby-forum.com/t/location-of-ancillary-files/139898/5 "2008-06-09T00:38:47Z")

</div>

On Jun 8, 2008, at 2:42 PM, Frederick C. wrote:

> > 
> 
> I don’t think rails has a strong opinion since the convention would be  
> to put it in the db 🙂

I have /app/configs for my own storage of read-only setup files for  
stuff I’d rather define in text than code (then load, parse, cache).

However, aside from storage location, you’ll have a much larger issue  
of concurrency access. You need to prevent readA-readB-writeB-writeA  
or you’ll end up with multiple orders having the same number. In a  
classic array of mongrels deployment, or even in the new mod\_rails, I  
imagine that would be very difficult.

For something with very high volumes of accesses like an auction a  
traditional db might be too slow, but designing your own thread\_lock  
system will be much, much slower, especially in a language like Ruby.

If you’re usually running a big db like MySQL, SQLServer, etc, and  
just don’t want the weight, then maybe consider SQLite3 for a case  
like this. Something new to learn, but it’s small and fast.

– gw
