myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2876] branches/datasets/app/models/pack.rb: Fix


From: noreply
Subject: [myexperiment-hackers] [2876] branches/datasets/app/models/pack.rb: Fix to allow both ways of specifying workflow versions when adding to a pack via URL
Date: Thu, 8 Dec 2011 10:55:57 -0500 (EST)

Revision
2876
Author
fbacall
Date
2011-12-08 10:55:57 -0500 (Thu, 08 Dec 2011)

Log Message

Fix to allow both ways of specifying workflow versions when adding to a pack via URL

Modified Paths

Diff

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]