Search code examples
grailsgrails-2.0grails-controller

Grails: Incompatible Strings for Range: starting String is longer than ending string


I have the following action in one of my controllers:

def logUpdate() {
    def report = Report.findById(params.id)
    def update = report.reportLog[params.logIndex..-1]
    render(template: "/report/LogTemplate", model: [update: update])
}

And when this action is called the app throws an exception with the message "Incompatible Strings for Range: starting String is longer than ending string"


Solution

  • Try to convert the logIndex parameter to an integer:

    def logIndex = params.int('logIndex')
    def update = report.reportLog[logIndex..-1]