passing intance variable from controller application_controller.rb to view template

Hi, guy.

How to pass a variable from application_controller.rb to view template. Whatever it is what kind of variable. I just want to pass the variable value to template.

Thank you.

In a method in the controller say
@my_variable = the_value

Call that method from the action being performed and access
@my_variable in the view.

Thanks Colin,
I solved this problem, if i do as you said , it just works in normal controller, not in application_controller.rb

I should do like this ,

before_filter :my_var

def my_var
@my_var = ‘a string’
end

So it works in view as normally variable invoked.

coolesting d. wrote in post #1018357:

Hi, guy.

How to pass a variable from application_controller.rb to view template.
Whatever it is what kind of variable. I just want to pass the variable
value
to template.

Thank you.

class Animal
  @val = 10

  def self.val
    @val
  end

end

class Dog < Animal
  def some_action
    @val_from_app_controller = Animal.val
    puts @val_from_app_controller
  end
end

controller = Dog.new
controller.some_action

--output:--
10