Sha256: 55abd95bb9e1a9be953bcde3f06eaeed84c74ccf58e83f81b27f6ffe11f4cf53

Contents?: true

Size: 962 Bytes

Versions: 8

Compression:

Stored size: 962 Bytes

Contents

module ActiveScaffold::Actions
  module Subform
    def edit_associated
      do_edit_associated
      render :action => 'edit_associated', :formats => [:js], :readonly => @column.association.options[:readonly]
    end

    protected

    def do_edit_associated
      @parent_record = params[:id].nil? ? new_model : find_if_allowed(params[:id], :update)
      generate_temporary_id(@parent_record, params[:generated_id]) if @parent_record.new_record? && params[:generated_id]
      @column = active_scaffold_config.columns[params[:child_association]]

      # NOTE: we don't check whether the user is allowed to update this record, because if not, we'll still let them associate the record. we'll just refuse to do more than associate, is all.
      @record = @column.association.klass.find(params[:associated_id]) if params[:associated_id]
      @record ||= build_associated(@column.association, @parent_record)
      @scope = params[:scope]
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
active_scaffold-3.4.7 lib/active_scaffold/actions/subform.rb
active_scaffold-3.4.5 lib/active_scaffold/actions/subform.rb
active_scaffold-3.4.4 lib/active_scaffold/actions/subform.rb
active_scaffold-3.4.3 lib/active_scaffold/actions/subform.rb
active_scaffold-3.4.2 lib/active_scaffold/actions/subform.rb
active_scaffold-3.4.1 lib/active_scaffold/actions/subform.rb
active_scaffold-3.4.0.1 lib/active_scaffold/actions/subform.rb
active_scaffold-3.4.0 lib/active_scaffold/actions/subform.rb