SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Where to place ruby/non-ruby files & how to reference them

    Hallo -- I have a couple of YAML files that my code needs to read in a web app -- my problem is that I have no idea where to place these for access from everywhere in my app (tests & all) with a single filename.
    So, for instance, I could write:
    Code:
    obj=YAML.load_file(<filename>)
    Where filename would be the same no matter where I called it from -- like maybe "app_root/shared/obj.yml".
    Maybe this points out a larger issue I have with file organisation in ruby, a subject which I must admit I am not totally clear on.
    Any & all help, advice, & tips are *greatly* appreciated!
    Cheers,
    doug.

  2. #2
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Generally, places like ./vendor are reserved for this.

  3. #3
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers for that -- I've been using subdirectories in ./lib (eg. ./lib/filter/) and including them in the ADDITIONAL_LOAD_PATHS in enviroment.rb.
    Does anyone think there could be a problem w/ this approach?
    & is there a general ruby way of organising files?
    Cheers,
    doug.

  4. #4
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As you pointed out the only real issue is that you were modifying the ADDITIONAL_LOAD_PATHS, however I guess it's still needed for ./vendor as well, so no the only thing is you are just going against the grain of how rails works

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I also use lib.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •