Convention over configuration and the Rails.root-tmp-folder

Hi,

I started to write a tiny rails app which comes completely as a ruby gem. Since this app has a big cousin in rails I did not want to use another framework like sinatra.

Since the app is a gem, I do not want it to store runtime-files in the tmp-folder. So I thought I should not stay with the convention but configure the location of the tmp-folder. But as far as I can see, there is no way to configure it.

I searched the source code and found lines like this one:

./railties/lib/rails/application/configuration.rb: @cache_store = [ :file_store, “#{root}/tmp/cache/” ]

As one can see, the tmp-folder does not follow convention over configuration but is hard coded.

So what about adding a configuration option? I am using Rails 4.1.

Regards
Thomas

You’re contradicting yourself. The /tmp folder is 100% convention and 0% configuration. Therefore it’s all convention over configuration. :slight_smile:

:wink:

I understand convention over configuration not the same as you do: you do not need to configure if your are fine with the convention, but you can, if you want or must. Like in ActiveRecord, when the table names can be derived from the class names but can also be declared, when you have a legacy db.

But it’s very easy to change:
In your app’s configuration.rb

config.cache_store = ``:file_store``, ``"/path/to/cache/directory"

:wink:

I understand convention over configuration not the same as you do: you do not need to configure if your are fine with the convention, but you can, if you want or must. Like in ActiveRecord, when the table names can be derived from the class names but can also be declared, when you have a legacy db.

The configuration is one level higher, when you pick a cache_store:

config.cache_store = ``:file_store``, ``"/path/to/cache/directory”

(from the caching guide)

—Matt Jones