On 9/12/05, Kimball Larsen
<kimball-MceZc52A0j6Pgb8tOZhbtAC/G2K4zDHf@public.gmane.org>
wrote:>
> As a follow up to my prior post about getting to the controller name,
> I would like now to build a list of controllers for which I don''t
> want to show the menu.
>
> In: /app/controllers/application.rb I have:
>
> NO_MENU_CONTROLLER = [''bar'',
''bam''].freeze
>
> But, when I try to reference NO_MENU_CONTROLLER from w/in an .rhtml,
> I get the following:
>
> uninitialized constant NO_MENU_CONTROLLER
>
> Extracted source (around line #13):
>
> 10: <%= @content_for_layout %>
> 11: </div>
> 12: <%> 13: NO_MENU_CONTROLLER
> 14: #unless controller.controller_name in
> @NO_MENU_CONTROLLER
> 15: # render(:partial => "shared/menu")
> 16: #end
>
>
> So, how do you define a global constant, and how do you then
> reference it?
Hi,
my guess is that to use a frozen object in your view it needs to be an
instance variable, preceded with the @ sign.
However, you could try specifying global constants in ruby config files,
such as environment.rb. In that case you would put something like
NO_MENU_CONTROLLER = [''bar'', ''bam'']
to such a file and then access NO_MENU_CONTROLLER (no @) from the controller
or view.
--
Agnieszka Figiel
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails