bearhunterUA
bearhunterUA

Reputation: 259

Get info from database in grails

Im newbie in Grails and now Im trying get one parametr from database. So I have domain class:

class Category {

    String category
    String description

    static mapping = {
        table 'categorydescription'
        category column: 'category'
        description column: 'description'
        version false
        cache true
    }
}

and want see "description" on index page, how can I do that? I tried

def index = {
        List<Category> сategoryInfo = Category.list()

        renderIndex(   
                сategoryInfo
        )
    }

and in view

<g:each in="${categoryInfo}" var="p">

    <li>${p.description}</li>
</g:each>

but see nothing...

Upvotes: 1

Views: 73

Answers (2)

swapy
swapy

Reputation: 290

what is that method renderIndex

renderIndex(   
            сategoryInfo
    )

you just need to pass the model. Replace that method call with [сategoryInfo:сategoryInfo]

Upvotes: 2

aldrin
aldrin

Reputation: 4572

Lookup the docs on querying Querying with GORM. That should tell you all you need to see the value of description on the index page

Upvotes: 0

Related Questions