Should I worry about Rails abandonment warnings?

When working with any structure with which you are not 100% familiar, I found it advisable to try to understand and clear any extraneous warnings, if only you have more chances to notice real errors when they occur.

Recently, I get the following:

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

It seems that nothing has broken in my current codebase, but I'm only worried because I don't fully understand the warning. I thought it was best not to use @model in your particles.

However, this warning is triggered every time this particular β€œmodel” appears in its partial.

How can I explicitly assign it? I created @model in the controller and then call the partial collection (realizing this as the "rails" method).

Can someone explain what is happening here for me and what are the best practices in this situation? I'm not worried yet, but miles of warning tend to drown out the real result from my application.

+4
source share
2 answers

In 2.3.5, yes, you have to fix your code. You could do it

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

and it was perfect (@rocket_launcher was raised in partial). Never again. Now you have to do

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

However, your example

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

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

+1
source

After digging this lighthouse, I would not be too worried; until.

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

+3
source

Source: https://habr.com/ru/post/1286174/


All Articles