mercredi 2 septembre 2015

Use param value as loop range ruby on rails

Controller return error "bad value for range" when passing param as loop range limit, following is my code

def creategroups
        require 'fileutils'
        @gcount = params[:group_count]
        for i in (1..@gcount) do
            Fileutils::mkdir_p "/groups/group_#{i}"
        end
        render json: params
    end

here group_count is the number of groups to be created.

Aucun commentaire:

Enregistrer un commentaire