Trouble adding dynamic categories to menu

42 views
Skip to first unread message

Bryan

unread,
Nov 7, 2012, 5:31:08 AM11/7/12
to simple-n...@googlegroups.com
My application controller has this:

after_filter :set_var

def set_var
  @categories = Categories.all
end


My navigation config has this (snippet):

primary.item :equipment, 'Equipment', '#', do |equip|
  @categories.each do |cat|
      equip.item :cats_id, cat.name, '#'
  end
end

But I always get a "undefined method `each' for nil:NilClass"

What am I doing wrong?  Is it just not possible to do this?  It seems the before_filter is not actually being called before the navigation script.

I tried again with the before_filter just setting @test = "Test", and making a menu item with that, and I got a similar error

Thanks for the help

mjtko

unread,
Nov 7, 2012, 5:37:45 AM11/7/12
to simple-n...@googlegroups.com, bbe...@highleadpetroleum.com
On Wednesday, 7 November 2012 10:31:08 UTC, Bryan wrote:
My application controller has this:

after_filter :set_var
[snip] 
What am I doing wrong?  Is it just not possible to do this?  It seems the before_filter is not actually being called before the navigation script.

Hi Bryan,

Are you sure you mean to use set_var  in an after_filter rather than a before_filter?

Cheers,

Mark.

bbe...@highleadpetroleum.com

unread,
Nov 7, 2012, 8:47:10 PM11/7/12
to simple-n...@googlegroups.com, bbe...@highleadpetroleum.com
That was it!  Sometimes it takes someone else looking at your code to notice something so obvious.  Thanks!
Reply all
Reply to author
Forward
0 new messages