Question

I am sure I am missing something obvious, but I cannot figure it out.

I have one partial that I am using in both the index and show views. The partial behaves as expected when called from the index, but throws a undefined variable or method exception when called from the show.

Here is my error:

undefined local variable or method `jid' for #<#<Class:0x007fe583bb03a8>:0x007fe586a98580>

Here is the render call from the Show view (this one fails)

render :partial => 'outcome_chart', :locals => {:jid => @journal.id, :code => @journal.code }

Here is the render call from the Index view (this one works)

render :partial => 'outcome_chart', :locals => {:jid => j.id, :code => j.code }

Here is my partial, I am using HAML syntax

.col-md-12{:id => "journal_chart_#{jid}", :style => 'height: 200px'}
   Chart will load shortly

- series_labels = []
- recommendations_order.each {|r| series_labels.push({label: r }) }
:javascript
  make_journal_outcome_chart("#{jid}", "#{code}", "#{recommendations_order.join(',')}");

Thanks in advance!

Was it helpful?

Solution

may be you are calling it from any other form and the locals needs to be passed from there as well – rubyist Oct 24 at 19:14

Found where there was a second call that I had overlooked. Thanks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top