I’ve tried very hard to understand file_field and how to determine
local_path. However, I’m running into some issues and I believe it’s
probably due to the different behaviors of file_field and local_path
First, here’s my issue.
I’m successfully parsing a yaml file using the following code (supplying
only what’s necessary here):
I’ll describe what I’m doing step by step and what I’ve accomplished so
Admin user wants to upload a new theme. A new theme houses the
following file/directory structure:
– blue_lagoon (folder and the theme name)
– images (folder)
– layouts (folder)
– stylesheets (folder)
– swfs (folder)
blue_lagoon.yml (yaml config file that houses some information)
- Admin user goes to themes index and clicks new. (working)
- Admin user clicks browse and selects the blue_lagoon.yml file.
- Admin user clicks upload. (working)
- Many validation checks are performed to ensure that a yml file is
being selected, and that it contains all of the pertinent information.
If it fails validation, notifications are sent to the admin user.
- Once everything is validated, the yml file is moved by rails to a
temporary folder and parsed. The information is then stored in a merged
parameter and sent to the model to be saved. (working)
- The theme model now contains a complete record of the
blue_lagoon.yml file. (working)
----- so far so good
----- here is where I’m running into some issues now
- Now I want to call an after_save method that will dir glob the
location that the (original) blue_lagoon.yml file was uploaded from, and
begin to mass create and upload the information to the public/themes
The problem is I don’t know how to find the local_path to the current
upload because rails moved it to the temp folder. If I try:
@files = params[:theme_upload][:upload].local_path
… it will return the temp directory path, not the true path.
Any help would be appreciated as well as any advice going forward on