Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

File#compute_url() does not consider nested models. #29

Open
richardkmichael opened this issue Feb 8, 2013 · 0 comments
Open

File#compute_url() does not consider nested models. #29

richardkmichael opened this issue Feb 8, 2013 · 0 comments
Labels
Milestone

Comments

@richardkmichael
Copy link
Owner

url = route_helpers.send(path_method_name, model)

Nested resources need a URL through their parent resource(s), and it must honour the retrieving request's path (in case they belong_to multiple models), ex. /path/via/gallery1/photo/1/file, /path/via/gallery/10/photo/1/file, /path/via/person/5/photo/1/file.

Approaches

  1. How can we obtain the request or URL from the controller when inside the model?
    Use Thread.current to store the request. Handled easily by the request_store gem. Then use the Rails router to re-parse the request.url? Or, put only the requisite parts of the parsed request into the Thread local instead of the entire request?
  2. Could we decorate the model using ActionView (like FormBuilder) on the way out of the controller?

Can @article.url call a Proc, which is executed with the binding of the view [controller?] to access the request?

def url
  Proc.new do
    # Access the request ... ?  We can capture the request using a Thread local.
  end.call
end
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant