Reputation: 1160
When I try to render a partial in an AJAX response it's saying undefined local variable or method 'campaign'
In create.js.erb
:
$("#progress").html("<%= j(render 'campaigns/progress_bars', locals: {campaign: @bid.campaign}) %>");
And then whenever I refer to it in the partial I just use something like:
<%= campaign.option_1 unless campaign.blank? %>
I use this partial elsewhere in the app and it works just fine.
Upvotes: 0
Views: 471
Reputation: 1160
Turns out it's necessary to use the partial
keyword in this scenario:
$("#progress").html("<%= j(render partial: 'campaigns/progress_bars', locals: {campaign: @bid.campaign}) %>");
I'm still not sure when and why that is necessary but it was the fix for this problem.
Upvotes: 2