controller variables in layout

I think the answer partially depends on what data you are trying to
display. If the data is static, or related to something predictable,
like the date, I would create a helper function and create the data in
there. There might be cases where the data you want needs to come
from the database though, and for that I would create a before filter:

before_filter :do_stuff

def do_stuff

You should read up on before filters, there are more options that make
them conditional and such that can come in handy.

Read more here