support limit parameter in #index
[arvados.git] / app / controllers / application_controller.rb
index d3427160cbbfd249476264441f4ec58f4a1199ee..cc8b2c35e0c2946f71b3685d46aa637a23e6d397 100644 (file)
@@ -77,6 +77,13 @@ class ApplicationController < ActionController::Base
           where(*conditions)
       end
     end
+    if params[:limit]
+      begin
+        @objects = @objects.limit(params[:limit].to_i)
+      rescue
+        raise "invalid argument (limit)"
+      end
+    end
     @objects.uniq!(&:id)
     if params[:eager] and params[:eager] != '0' and params[:eager] != 0 and params[:eager] != ''
       @objects.each(&:eager_load_associations)