My app has a select box for users to choose a "venue". This select box is, as you would expect, in a form. I also have an action somewhere on the page that creates a new venue via AJAX. After the new venue is created, I would like to updated the venue select box to reflect this.
My solution was to put the select box in a partial and render the partial from the create action in the controller.
<div id="venue_select" style="clear: both;">
<%= render :partial => 'venue/venue_select_box' %>
</div>
The partial looks like this:
<%= f.collection_select :venue_id, @user_venues, :id, :name, :prompt => 'Select a venue' %>
where f is the form reference:
<% form_for :shows do |f| %>
The problem is that f is undefined in the partial, so I get an error. One solution would be to include the entire form, but I feel like that should not be necessary because I am not updating the entire form. Any ideas on how to go about this?