Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7553 (closed defect: invalid)

Opened 3 years ago

Last modified 2 years ago

deprecation warning for @flash on line of 121 of partials.rb

Reported by: rafeco Assigned to: bitsweat
Priority: normal Milestone: 1.2.4
Component: ActionPack Version: 1.2.1
Severity: trivial Keywords: deprecation
Cc:

Description

When I run functional tests for my project (under Rails 1.2.2), I get the following deprecation warnings:

Started
DEPRECATION WARNING: @flash is deprecated! Call flash.is_a? instead of @flash.is_a?. Args: [ActionView::Base::ObjectWrapper]  See http://www.rubyonrails.org/deprecation for details. (called from add_object_to_local_assigns! at /Users/rafeco/seymour/config/../vendor/rails/actionpack/lib/action_view/partials.rb:121)
...DEPRECATION WARNING: @flash is deprecated! Call flash.is_a? instead of @flash.is_a?. Args: [ActionView::Base::ObjectWrapper]  See http://www.rubyonrails.org/deprecation for details. (called from add_object_to_local_assigns! at /Users/rafeco/seymour/config/../vendor/rails/actionpack/lib/action_view/partials.rb:121)
.
Finished in 0.095503 seconds.

The warnings are presented when I render the following partial in my layout:

<% if self.flash[:success] %>
    <div class="feedback_banner success"><%= self.flash[:success] %></div>
<% end %>
<% if self.flash[:failure] %>
    <div class="feedback_banner failure"><%= self.flash[:failure] %></div>
<% end %>
<% if self.flash[:notice] %>
    <div class="feedback_banner notice"><%= self.flash[:notice] %></div>
<% end %>

If I take off the "self." in front of the calls to "flash", I get even more warnings.

It seems like these warnings are being presented incorrectly.

Change History

(in reply to: ↑ description ) 02/13/07 19:23:03 changed by rafeco

  • severity changed from normal to trivial.

OK, the problem is that my partial was called "flash.rhtml", so when it got to the method:

      def add_object_to_local_assigns!(partial_name, local_assigns, object)
        local_assigns[partial_name.intern] ||=
          if object.is_a?(ActionView::Base::ObjectWrapper)
            object.value
          else
            object
          end || controller.instance_variable_get("@#{partial_name}")
      end

There's no object assigned to the local assigns under the partial name, and there's no deprecated object passed in to the partial call, so it tries to grab an instance variable from the controller with the name of the partial. Since my partial is called "_flash.rhtml", it tries to grab @flash, which triggers the deprecation warning. Not sure if this bug merits fixing.

02/13/07 20:17:26 changed by bitsweat

  • keywords set to deprecation.
  • owner changed from core to bitsweat.

Great troubleshooting. That's tricky.

03/19/07 18:15:33 changed by dcmanges

This shouldn't happen on edge after [6399], but I don't have time to verify right now.

06/18/07 06:32:44 changed by wycats

  • status changed from new to closed.
  • resolution set to invalid.

12/26/07 18:59:35 changed by JohnPostlethwait

This is still happening in Rails 2.0.2, not sure if there was any intention to throw a warning or anything when this happens but no indication is currently given. As detailed above, renaming the partial from _flash.html.erb to something like _flash_notices.html.erb works around the issue.