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/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/e7404664c6e1b81a2d21344b175ad484%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to