Module: ActiveScaffold::Actions::Subform

Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/actions/subform.rb

Instance Method Summary collapse

Instance Method Details

#edit_associatedObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/actions/subform.rb', line 3

def edit_associated
  @parent_record = params[:id].nil? ? active_scaffold_config.model.new : 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 ||= @column.association.klass.new

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

  render :action => 'edit_associated'
end