Module: Acts::ArchiveController::UpdateMethods

Defined in:
lib/acts_as_archive_controller.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) edit



152
153
154
155
156
157
158
# File 'lib/acts_as_archive_controller.rb', line 152

def edit
  record.attributes = params[self.class.singular_name.to_sym]

  respond_to do |format|
    format.html { render :template => 'admin/shared/edit', :locals => { :object => record }}
  end
end

- (Object) update



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/acts_as_archive_controller.rb', line 160

def update
  record.attributes = params[self.class.singular_name.to_sym]

  respond_to do |format|
    if @commit_type == 'preview' && record.valid?
      format.html { render :template => 'admin/shared/update_preview', :locals => { :object => record }, :layout => 'admin/admin_preview' }
      format.xml  { render :xml => record, :status => :created, :location => record }
    elsif @commit_type == 'save' && record.save
      format.html { render :template => 'admin/shared/update' }
      format.xml  { head :ok }
    else
      format.html { render :template => 'admin/shared/edit', :locals => { :object => record }, :status => :unprocessable_entity }
      format.xml  { render :xml => record.errors, :status => :unprocessable_entity }
    end
  end
end