Modified: branches/datasets/app/models/pack.rb (2875 => 2876)
--- branches/datasets/app/models/pack.rb 2011-12-08 14:57:21 UTC (rev 2875)
+++ branches/datasets/app/models/pack.rb 2011-12-08 15:55:57 UTC (rev 2876)
@@ -590,11 +590,11 @@
contributable = nil
# Use Rails' routing to figure out the URL
- resource = ActionController::Routing::Routes.recognize_path(uri.path, :method => :get)
- model_name = resource[:controller].classify.model_alias
+ request = ActionController::Routing::Routes.recognize_path(uri.path, :method => :get)
+ model_name = request[:controller].classify.model_alias
- if Conf.contributable_models.include?(model_name) && resource[:action] == "show"
- contributable = eval(model_name).find_by_id(resource[:id])
+ if Conf.contributable_models.include?(model_name) && request[:action] == "show"
+ contributable = eval(model_name).find_by_id(request[:id])
else
is_remote = true # Treat as a remote entry
end
@@ -612,7 +612,12 @@
end
# Check if version was specified in the uri
- entry.contributable_version = resource[:version]
+ entry.contributable_version = request[:version]
+
+ # maybe it was as a query instead?
+ if uri.query
+ entry.contributable_version = CGI.parse(uri.query)["version"].first.try(:to_i)
+ end
else
errors_here.add_to_base('The item the link points to does not exist.')
end