Sha256: 44009c82d8e6f0050851ae3358269f7368206c4ef499e82711accfdcc4d68791

Contents?: true

Size: 1.02 KB

Versions: 20

Compression:

Stored size: 1.02 KB

Contents

module ActiveScaffold::Actions
  module Subform
    def edit_associated
      do_edit_associated
      render :action => 'edit_associated.js'
    end

    protected

    def do_edit_associated
      @parent_record = params[:id].nil? ? new_model : find_if_allowed(params[:id], :update)
      @column = active_scaffold_config.columns[params[: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 ||= if column.singular_association?
        parent_record.send("build_#{column.name}".to_sym)
      else
        parent_record.send(column.name).buildbuild_associated(column, parent_record)
      end

      @scope = "[#{@column.name}]"
      @scope += (@record.new_record?) ? "[#{(Time.now.to_f*1000).to_i.to_s}]" : "[#{@record.id}]" if @column.plural_association?
    end

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
active_scaffold-3.1.20 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.19 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.18 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.17 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.15 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.14 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.0.26 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.13 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.12 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.0.25 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.11 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.10 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.9 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.8 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.7 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.6 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.5 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.0.24 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.4 lib/active_scaffold/actions/subform.rb~
active_scaffold-3.1.3 lib/active_scaffold/actions/subform.rb~