I just ran into an interesting warning and since it took me a few minutes to figure it out I thought I share it here.
I’m rendering a partial template like this:
render :partial => 'list_items/list_item', :locals => { :list => @list, :list_items => @list_item}
Now, when running this code I got this deprecation warning:
DEPRECATION WARNING: @list_item will no longer be implicitly assigned to list_item. (called from _run_erb_app47views47list_items47_list_item46html46erb_locals_list_list_item_list_items_object at /home/stefan/projects/Memento/app/views/list_items/_list_item.html.erb:1)
The problem here was that in the partial I’m using the local variables are named list and list_item, in the render call however I’m passing in list and list_items. Everything still works because rails implicitly assigns @list_item to the local variable list_item. This is what the warning says…
So the fix is simply removing the additional “s”.
render :partial => 'list_items/list_item', :locals => { :list => @list, :list_item => @list_item}
Not specifically hard but yet another prove that taking “a close look” at your own code is always difficult ;-) I bet a peer what have see the problem in a sec …
I'm a Software Developer, currently working at 
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment