views:

705

answers:

2

When dealing with any framework with which you are not 100% familiar, I've found it advisable to attempt to understand and clean up any extraneous warnings, if only so that you have a better chance of noticing real errors when they occur.

The one I've been getting lately has been:

 DEPRECATION WARNING: @model will not longer be implicitly assigned to model

It appears not to be breaking anything in my current code base, but I'm worried just because I don't understand the warning completely. I thought it was generally better NOT to use @model in your partials.

Nonetheless this warning has been getting invoked every time this particular 'model' appears in its partial.

How should I explicitly assign it? I've created the @model in a controller, and am then calling the partial with a collection (understood this to be the 'railsy' method.)

Can anyone explain what's going on here to me, and what best practices are in this situation? I'm not freaking out yet, but the miles of warning tend to drown out the real output from my application.

+2  A: 

After digging up this Lighthouse ticket, I wouldn't be too concerned; yet.

Inappropriate "@variable will no longer be implicitly assigned to variable" message

mwilliams
Interesting. Thanks!
Joe
A: 

In 2.3.5, yes, you should fix your code. You used to be able to do this

@rocket_launcher = RocketLauncher.find(params[:id])
page.insert_html :bottom, 'ajax_this', :partial => 'rocket_launcher'

and it was fine (@rocket_launcher was picked up in the partial). No longer. Now you must do

page.insert_html :bottom, 'ajax_this', :partial => 'rocket_launcher', :locals=>{:rocket_launcher=>@rocket_launcher}

That said, your example

<%=render :partial => "rocket_launcher", :collection => @rocket_launchers %>

is cool and the deprecation warnings seen in 2.2.x should be fixed now (in 2.3.5).

Yar

related questions