mercredi 11 novembre 2015

In a Rails 3 app I am trying to populate an array from the database once instead of reloading it for every page accessed

The following pull down menu is on every page of our web site after someone logs in. For some accounts there are over 200 items in the pull down menu. I don't want to reload the array for each page.

the pull down menu:

<%= select_tag "current_item", options_from_collection_for_select(@all_user_items, :id, :name, @current_item) %>

in controller:

@all_user_items = Item.where("user_id = ?, current_user.id)

Do I have to use a global variable?

Thanks for your help.

Aucun commentaire:

Enregistrer un commentaire