Sha256: 46570f306a211c2790bee1b1782d7233b6fde375d496b4b21015f90549c1d604

Contents?: true

Size: 1005 Bytes

Versions: 43

Compression:

Stored size: 1005 Bytes

Contents

module ActiveScaffold::Actions
  module Subform
    def edit_associated
      do_edit_associated
      render :action => 'edit_associated'
    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).build
      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

43 entries across 43 versions & 2 rubygems

Version Path
active_scaffold_vho-4.0.0 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.14 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.13 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.12 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.11 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.10 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.9 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.8 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.7 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.6 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.5 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.4 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.3 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.2 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.1 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.2.0 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.0.31 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.1.8 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.0.30 lib/active_scaffold/actions/subform.rb
active_scaffold_vho-3.0.29 lib/active_scaffold/actions/subform.rb