Sha256: f8f9319b1836750622b50874e923fb30140b34b24bdb2152a199a033816688c4

Contents?: true

Size: 617 Bytes

Versions: 1

Compression:

Stored size: 617 Bytes

Contents

module FieldTest
  class ExperimentsController < BaseController
    def index
      @active_experiments, @completed_experiments = FieldTest::Experiment.all.sort_by(&:id).partition { |e| e.active? }
    end

    def show
      @experiment = FieldTest::Experiment.find(params[:id])

      @per_page = 200
      @page = [1, params[:page].to_i].max
      offset = (@page - 1) * @per_page
      @memberships = @experiment.memberships.order(created_at: :desc).limit(@per_page).offset(offset).to_a
    rescue FieldTest::ExperimentNotFound
      raise ActionController::RoutingError, "Experiment not found"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
field_test-0.2.0 app/controllers/field_test/experiments_controller.rb