Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] Make path to tmp directory configurable

#2379

To ease certain types of deployments, it's desirable that the tmp directory be configurable in the Initializer block rather than hardcoded in. This patch implements that option as well as making other parts of Rails respect the new option.

This (along with ticket #2350 [PATCH] LogTailer ignores config.log_path) makes it possible to deploy Rails apps as ruby gems, keeping all instance-specific data in a single directory while the application code lives in the gem home.

Reported by Phil Hagelberg · March 31st, 2009 @ 12:12 AM

State: new
Milestone: 3.0.6
Assigned to: Yehuda Katz (wycats) Yehuda Katz (wycats)
Importance: none

Activity

  1. Jeff Hodges
    Jeff Hodges

    +1

    This is a solid patch. I would like the task description "Clears all session files in tmp" changed to desc "Clears all session files in the tmp directory" and similar to the other one. However, that's just being picky.

    March 31st, 2009 @ 12:15 AM

  2. Phil Hagelberg
    Phil Hagelberg
    • Tag changed from configuration to configuration, patch

    March 31st, 2009 @ 02:23 AM

  3. Xavier Noria
    Xavier Noria

    Two things I'd like to improve:

    • I think tmp_dir may be useful to the end user, what about documentation for it.

    • I think it is better style not to mix slashes and File.join. If you use File.join then leave slashes to it.

    • The analogous accessors for lots of stuff end with "_path". To be consistent in that naming I'd call it "tmp_path".

    March 31st, 2009 @ 05:01 AM

  4. Phil Hagelberg
    Phil Hagelberg

    Thanks, fellas. I will make these changes and attach another patch.

    I added comments for the tmp_dir accessor; I believe those should get picked up by RDoc. Is there somewhere else it should be documented?

    March 31st, 2009 @ 05:08 AM

  5. Phil Hagelberg
  6. Shane Liebling
    Shane Liebling

    I was wondering if this was going to get rolled into the mainline rails anytime soon - I for one could really use it!!

    July 12th, 2009 @ 09:39 PM

  7. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from configuration, patch to bugmash, configuration, patch

    August 7th, 2009 @ 02:28 PM

  8. Kieran P
    Kieran P

    +1, but the patch supplied does not apply cleanly to Rails 3.0 (master). I've uploaded a modified patch that does.

    August 8th, 2009 @ 07:05 AM

  9. Kieran P
    Kieran P

    Previous file wasn't a proper patch. This one should be better.

    August 8th, 2009 @ 07:28 AM

  10. Dan Pickett
    Dan Pickett

    +1 for the feature

    verified that the patch applies cleanly to master

    There currently isn't any tests associated with this patch - would it be possible to include tests on this? (I'm asking if its possible, not being patronizing :-) )

    August 8th, 2009 @ 11:52 PM

  11. José Valim
    José Valim
    • Assigned user set to Yehuda Katz (wycats)
    • Milestone cleared.

    I was discussing about this feature with Yehuda a week ago. He told me that all Rails paths should be configurable, like Rails.paths.vendor #=> RAILS_ROOT/vendor. Not sure if he is already working on that with Carl, but I'm assigning it to him.

    August 9th, 2009 @ 12:08 AM

  12. Rizwan Reza
    Rizwan Reza

    +1 I agree with Yehuda on all Rails path being configurable... that would be awesome!

    August 9th, 2009 @ 12:16 AM

  13. Elad Meidar
    Elad Meidar

    +1 on idea and approach to have all paths as configurable.

    patch applies cleanly but contains a typo (fixed patch attached), i was unable to think of a proper way to test it, nor where other paths are tested.
    I also think that it should be somewhat a Configuration accessor, other than the Rails instance.

    August 9th, 2009 @ 05:25 AM

  14. Kieran P
    Kieran P

    Michael (Koz) suggested (on IRC) that it be Rails.tmpdir to match Dir.tmpdir used other places in Rails, so I based the getter/setter from public_path, rather than make a Configuration accessor as in the original patch.

    August 9th, 2009 @ 05:36 AM

  15. Yehuda Katz (wycats)
    Yehuda Katz (wycats)

    On master, we have already moved toward a more flexible way to describe paths. Check out this block from configuration.rb

          @paths = Rails::Application::Root.new(root_path)
          @paths.app                 "app",             :load_path => true
          @paths.app.metals          "app/metal",       :eager_load => true
          @paths.app.models          "app/models",      :eager_load => true
          @paths.app.controllers     "app/controllers", builtin_directories, :eager_load => true
          @paths.app.helpers         "app/helpers",     :eager_load => true
          @paths.app.services        "app/services",    :load_path => true
          @paths.lib                 "lib",             :load_path => true
          @paths.vendor              "vendor",          :load_path => true
          @paths.vendor.plugins      "vendor/plugins"
          @paths.tmp                 "tmp"
          @paths.tmp.cache           "tmp/cache"
          @paths.config              "config"
          @paths.config.locales      "config/locales"
          @paths.config.environments "config/environments", :glob => "#{RAILS_ENV}.rb"
    

    The basic idea is that we mirror the default directory structure for ease of understanding, but users can specify whatever paths they want for a part of the path hierarchy. Each virtual path can also have multiple physical paths. When Carl gets back from vacation we'll finish this up (we got detoured to work on the gem bundler) and write it up.

    August 9th, 2009 @ 10:00 AM

  16. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • Tag changed from bugmash, configuration, patch to configuration, patch

    August 9th, 2009 @ 10:00 AM

  17. Jeremy Kemper
    Jeremy Kemper
    • Milestone cleared.
    • Importance changed from to

    August 30th, 2010 @ 04:10 AM

  18. Jeremy Kemper
  19. Santiago Pastorino
  20. Santiago Pastorino
  21. Santiago Pastorino
    Santiago Pastorino
    • Milestone changed from 3.0.5 to 3.0.6

    February 27th, 2011 @ 03:15 AM