I have an instance variable, @pages, which needs to be set up in a
certain way at the end of several actions, so I thought to be clever and
do it in the following way:
# In my controller
after_action :prepare_admin_home_data, only:
[:adm_login,:adm_upload_selected]
def adm_login
...
render admin_pages_home_path
...
end
def prepare_admin_home_data
@pages=Dir["#{AMP_DIR}/*"]
logger.debug("+++++++++++ pages #{@pages.to_s}")
end
I can see from the logs, that @pages got the right value, but in my
view, it is nil. It seems that the HTML code is constructed before the
after_action is executed.
I understood the render() function in that way, that it only sets up
which ERB template is supposed to be used, but actual rendering would
occur only when the action has finished. Did I get this wrong?
Ronald
--
Posted via
http://www.ruby-forum.com/.