title: Rails, Edit page update in a window
body: <p>I have my code working so that I have a table of businesses.  There's a pencil icon you can click on the edit the business information.  The edit information comes up in a partial inside of a modal pop up box.  The only problem is that once they make the changes they want and click update, it sends them to the 'show' page for that business. What I want to happen is have the pop up box close and have it update the information. This is my update function in my controller.</p>
  
  <pre><code> def update
  @business = Business.find(params[:id])
  
  respond_to do |format|
    if @business.update_attributes(params[:business])
      flash[:notice] = 'Business was successfully updated.'
      format.html { redirect_to(business_url(@business)) }
      format.js
    else
      format.html { render :action =&gt; "edit" }
      format.xml  { render :xml =&gt; @business.errors, :status =&gt; :unprocessable_entity }
    end
  end
  </code></pre>
  
  <p>end</p>
  
  <p>I tried following railscast 43 and i created an .rjs file but I couldn't get that to work at all. My update was still taking me to the show page.  Any help would be appreciated.</p>
  
  <p>EDIT: Added some more code.</p>
  
  <pre><code>&lt;% form_for(@business) do |f| %&gt;
  &lt;%= f.error_messages %&gt;
  
  &lt;p&gt;
    &lt;%= f.label :name %&gt;&lt;br /&gt;
    &lt;%= f.text_field :name %&gt;
  &lt;/p&gt;
  ...
        &lt;%= f.label :business_category %&gt;&lt;br /&gt;
        &lt;%= f.select :business_category_id, @business_categories_map, :selected =&gt; @business.business_category_id %&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;%= f.label :description %&gt;&lt;br /&gt;
        &lt;%= f.text_area :description %&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;%= f.submit 'Update' %&gt;
      &lt;/p&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p>This is my form inside of my edit page which is being called through the index in a pop up by:</p>
  
  <pre><code>&lt;div id="popupEdit&lt;%=h business.id %&gt;" class="popupContact"&gt;
        &lt;a class="popupClose&lt;%=h business.id %&gt;" id="popupClose"&gt;x&lt;/a&gt;
        &lt;% if business.business_category_id %&gt;
          &lt;% @business = business  %&gt;
          &lt;%= render "business/edit" %&gt;
        &lt;% end %&gt;
      &lt;/div&gt;
  </code></pre>