def refresh_menu
@menu_pages = []
$menu_items.each do |id|
@menu_pages[id - 1] = Page.find(id)
end
end
$menu_items is just an array [1,2]. Obviously what I want to do is populate @menu_pages with all the pages found as per $menu_items.
Mind you,
@menu_pages = Page.all
works just fine. So how come I can’t add them one-by-one with Page.find(id)?
The error returned:
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Why not just do?…
And in relation to the error, where is
$menu_itemsdefined?