Forum: Ruby on Rails scope problem: controller class methods and helpers.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C1c81fa1d759141e41cc5e9db2b8fce4?d=identicon&s=25 jbc (Guest)
on 2009-03-02 16:46
(Received via mailing list)
http://pastie.org/404716

Only produces "hello", not "world".

Which is as designed, but how do I make it do what I want - namely,
set a variable in a class method, and have that variable available in
a view helper?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-03-02 16:48
(Received via mailing list)
On Mar 2, 3:25 pm, jbc <jcatt...@gmail.com> wrote:
> http://pastie.org/404716
>
> Only produces "hello", not "world".
>
> Which is as designed, but how do I make it do what I want - namely,
> set a variable in a class method, and have that variable available in
> a view helper?

Only instance variables of the controller are copied across to the
view (your bar is an instance variable of the class). easiest way
would probably be to have an accessor method for it and then you can
do controller.bar in your view.

Fred
This topic is locked and can not be replied to.