In_place_editor_field for select tag

I need to have a in_place_edit_field for select tag. I've been looking in /public/javascripts/console.js source and found Ajax.InPlaceCollectionEditor JS class which seems to be the right one I need. But the problem is that I use ajax in rails first time and I don't know how to use it in my rails application. I can't find anything in rails API, either. I've only found in_place_editor_field which I successfully use.

Thanks in advance for any suggestions.

I don't know when this thread started, but I've been using this for months now (it lives in app/helpers/application_helper.rb):

   # Example:    # class Soldier < ActiveRecord::Base; belongs_to :rank; end    # class Rank < ActiveRecord::Base; has_many :soldiers; attr_accessible :name; end

In my application, products are assigned to a category (Product belongs_to Category)

For example:

In your view:            <%= in_place_collection_field(product, :product, :category, @category_choices) %>

In the controller:

require 'set_product_category'

class ProductsController < AuthorizedController    in_place_edit_for :product, :name

   # XHR /products/set_product_category/1    include SetProductCategory end

In the set_product_category.rb file (Yes, I really have this comment...)

# similar to having: in_place_edit_for :product, :category # except that it ... actually, this probably could be abandoned! module SetProductCategory    def set_product_category      @product = Product.find(params[:id], :include => :category)      if category = Category.find(params[:value])        @product.category = category        @product.save!        render :text => @product.category_name, :layout => false      else        render :text => "No category with ID #{params[:value]}", :status => 422      end    end end

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com

I used that code in two places and putting in a separate module made it DRY. :wink:

-Rob

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com