Rails 1.2 is barking at me to use session[:foo] instead of @session[:foo]. (Actually, to be exact, it's saying "@session is deprecated! Call session. instead of @session." but session. makes no sense at all, right?).
I would love to change this, but I'm using markaby for all my templates, and if I remove the @ from session I get a nil object.
I guess that's slightly misleading but it's because '' is actually a
method call - like mystring.length.
I would love to change this, but I'm using markaby for all my templates,
and if I remove the @ from session I get a nil object.
Where abouts do you get the nil object? Could you post the section of
code that causes the error? It'd also be good to see the code you're
using to set the session variable.
under the covers, ruby turns methods like "." and ".=" into ""
and "="
If session() isn't available in Markaby, I'd send in a patch and bug
report/feature request and monkey-patch my local installation if the
deprecation warning is really bugging you.
under the covers, ruby turns methods like "." and ".=" into ""
and "="
Yeah, I guess I figured that... it's just kind of funny that the
deprecation message says that, since session. won't compile.
If session() isn't available in Markaby, I'd send in a patch and bug
report/feature request and monkey-patch my local installation if the
deprecation warning is really bugging you.
Yeah, I think I'll have to do that, since the solution
(#{helpers.session}) is pretty ugly.
Er, on the other hand... not sure if this is working after all. It
compiles but I think the if block is always true. Need to dig into
exactly how the #{} construct works.
In the meantime, if why or any other markaby heads are lurking, would
love to know how they're dealing with this.
I guess really what my question is is how does one get ahold of the
helpers from a markaby template. Actually I thought the helpers where
available directly markaby (like I'm using link_to, etc.), but it
definitely doesn't seem to work for session.
However, I think I'm not going to do the patch and wait for markaby to
put the fix into it's repository. (Hopefully it can be fixed in
markaby... the patch is to builder.rb!)
In the meantime, I've found this hackish workaround: if my main layout
page includes an empty .rhtml template, the helpers are made available.
Dorky, I know... but it works for now.
Ack... sorry... one more correction. The *only* issue is that of markaby
not getting rails helpers by default. Either applying the patch or
including at least one rhtml partial in every page (main layout, for
example) solves the problem. The #{} isn't necessary.