Sha256: e0d4265b5e32761b582a011a4b32272f7594aa0b052663879a1b05f879e7b39b

Contents?: true

Size: 735 Bytes

Versions: 2

Compression:

Stored size: 735 Bytes

Contents

class NestedFieldsController < ActionController::Base
  def add_nested_fields
    @association = params[:association].to_sym
    @builder = params[:builder].constantize
    @index = "#{Time.now.to_i}#{Time.now.usec}"
    @nested_partial = params[:nested_partial]
    @parent_form = params[:parent_form]

    parent_class = params[:parent_class].constantize

    @objects = params[:copy_parent_id] ?
               parent_class.find(params[:copy_parent_id]).send(@association).reverse :
               Array.new(1, parent_class.reflect_on_association(@association).klass.new)

    respond_to do |format|
      format.js { render :partial => 'nested_fields/add_nested_fields', :collection => @objects, :as => :object }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nested_fields-0.4.0 app/controllers/nested_fields_controller.rb
nested_fields-0.3.0 app/controllers/nested_fields_controller.rb