assuming i have a filter (which is being invoked before every action), how can I pass an object, which is fetched from the database in it to every view? I do not want to refactor
all my methods.
To vizualize:
I have a filter that sets an object, for example:
def god = God.find(1)
and I have 100 controllers, for each controllers 100 methods, which is 100 * 100 views.
Usually in the action you write something like :
def index = {
def something = Something.find(1)
[something: something]
}
the question is how can I pass God object as well, without having to modify the return array to
[something: something, god: god]
You would want an
afterinterceptor type to your filter for that.aftertakesmodelas an argument to the closure, and you can add god to that model.Here’s the relevant docs section.