I''m successfully using flash, but I''m unclear how the syntax actually works. In my controller I access it like this: flash[ ''foo'' ] But in the view I have to access it like this: @flash[ ''foo'' ] In my (apparently) limited understanding of Ruby syntax the former would be a local variable refence or a method call, but the latter is a class instance variable. What is it really? Thanks. Jack Christensen
flash[''foo''] means means call method ''flash'' then apply operator [] with argument ''foo'' to result. @flash in the view is just another member variable from Controller made available by magic in the View. I think ... Zsombor On Apr 7, 2005 2:09 AM, Jack Christensen <jack-BsDU1ACF2Bglk5EcyZIkJQ@public.gmane.org> wrote:> I''m successfully using flash, but I''m unclear how the syntax actually > works. In my controller I access it like this: > > flash[ ''foo'' ] > > But in the view I have to access it like this: > > @flash[ ''foo'' ] > > In my (apparently) limited understanding of Ruby syntax the former would > be a local variable refence or a method call, but the latter is a class > instance variable. What is it really? > > Thanks. > > Jack Christensen-- http://deezsombor.blogspot.com
Is flash not an array? Or am I confusing myself with PHP or Java''s use of square brackets [] for arrays? On Apr 7, 2005 3:40 AM, Dee Zsombor <dee.zsombor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> flash[''foo''] means means call method ''flash'' then apply operator [] > with argument ''foo'' to result. > > @flash in the view is just another member variable from Controller > made available by magic in the View. I think ... > > Zsombor > > On Apr 7, 2005 2:09 AM, Jack Christensen <jack-BsDU1ACF2Bglk5EcyZIkJQ@public.gmane.org> wrote: > > I''m successfully using flash, but I''m unclear how the syntax actually > > works. In my controller I access it like this: > > > > flash[ ''foo'' ] > > > > But in the view I have to access it like this: > > > > @flash[ ''foo'' ] > > > > In my (apparently) limited understanding of Ruby syntax the former would > > be a local variable refence or a method call, but the latter is a class > > instance variable. What is it really? > > > > Thanks. > > > > Jack Christensen > > -- > http://deezsombor.blogspot.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- - Frank FrankManno.com <a href="http://www.spreadfirefox.com/?q=affiliates&id=2496&t=1">Get Firefox!</a>
On Apr 7, 2005 8:40 PM, Dee Zsombor <dee.zsombor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> flash[''foo''] means means call method ''flash'' then apply operator [] > with argument ''foo'' to result.Not quite, it means find object ''flash'' and call the method []. In this case flash is likely to be a function that returns an object, could easily be an array though. The key thing being that [''foo''] calls object.[](''foo''), so although you treat it as an array, it could be anything.> @flash in the view is just another member variable from Controller > made available by magic in the View. I think ...Same as above, but the object is in class scope, rather than in either local scope or as a function. This is because the view can''t access variables in local scope to the controller, so they get put in to the class. Check the source if you''re really curious, but @flash[] just might work from the controller. -- Phillip Hutchings http://www.sitharus.com/ sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org / sitharus-QrR4M9swfipWk0Htik3J/w@public.gmane.org