I am using ruby 2.3.1 and rails 3.2.1. I need to initialize a variable called has_sub_menu = false
in application controller.
In my application i am using more than 30 controllers and only two controllers contains sub-menu, so i need to assign has_sub_menu = true
to these controllers to validate it in layout file.
This is my application.rb
has_sub_menu = false
some_controller01.rb
has_sub_menu = true
some_controller02.rb
has_sub_menu = true
I tried like this in layout.rb
,
if controller.has_sub_menu == true
show_menu_items
end
show_menu_items
will be available in that two controller and currently i am not able to access the has_sub_menu
value in layout file
I know in c# I can declare the variable as static and access it in any file using object.
Like wise how can i declare a variable in application
controller and assign different value to that variable in other two controller and I need to access that value in layout.rb file for sub-menu validation.
Aucun commentaire:
Enregistrer un commentaire