After much painstaking debugging, I've found that the cause of this
problem doesn't lie in Haml, but rather in ActionView. You'd get the
same results with an RHTML partial. You see, when rendering a partial,
ActionView creates a variable with the name of that partial. It then
looks for an instance variable with that name in the corresponding
controller, and assigns the partial-named variable to the controller
variable. In this case, your partial is named "flash"... so ActionView
looks for an instance variable by the name of "@flash" in your
controller, and assigns the "flash" variable to that. What it finds is
the deprecated "@flash" instance variable. It then overwrites the
"flash" method with that variable, causing it to spit deprecation warnings.
This means you have two choices. You could either simply rename the
partial, or just keep going with the deprecation messages. When "@flash"
is removed, all your references to "flash" will suddenly refer to the
actual flash method and all will be well (except the deprecation
messages you'll be getting).
Hope this was helpful,
- Nathan
DerGuteMoritz wrote:
> Hi Nathan,
>
> I have a partial layouts/_flash.haml with the following contents:
>
> - [:notice, :warning, :error].each do |flash_type|
> - if flash[flash_type]
> .flash{ :id => flash_type }= flash[flash_type]
>
> >From my layout view, I merely render it like this:
>
> = render :partial => 'layouts/flash'
>
> Those are the deprecation warnings:
>
> .DEPRECATION WARNING: @flash is deprecated! Call flash.is_a? instead
> of @flash.is_a?. Args: [Hash] See http://www.rubyonrails.org/deprecation
> for details. (called from rec_merge! at /my_rails_app/config/../vendor/
> plugins/haml/lib/haml/engine.rb:713)
> DEPRECATION WARNING: @flash is deprecated! Call flash.[] instead of
> @flash.[]. Args: [:notice] See http://www.rubyonrails.org/deprecation
> for details. (called from _haml_render at (eval):8)
> DEPRECATION WARNING: @flash is deprecated! Call flash.[] instead of
> @flash.[]. Args: [:warning] See http://www.rubyonrails.org/
> deprecation for details. (called from _haml_render at (eval):8)
> DEPRECATION WARNING: @flash is deprecated! Call flash.[] instead of
> @flash.[]. Args: [:warning] See http://www.rubyonrails.org/
> deprecation for details. (called from _haml_render at (eval):12)
> DEPRECATION WARNING: @flash is deprecated! Call flash.[] instead of
> @flash.[]. Args: [:error] See http://www.rubyonrails.org/deprecation
> for details. (called from _haml_render at (eval):8)
>
>
> Thanks for your time!
>
> Moritz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---