Sha256: 6ce3b08eb283ff0c7e3d7575ecf75a95fb65871ac4a46264b0ca09b3bd5211f5

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

class DetailsController < ApplicationController

  before_filter :authenticate
  before_filter :authenticate_with_admin

  def show
    @detail = Detail.find(params[:id])
    switch_to_admin_layout
  end

  def new
    @detail = Detail.new
    switch_to_admin_layout
  end

  def edit
    @detail = Detail.find(params[:id])
    switch_to_admin_layout
  end

  def create
    @detail = Detail.new(params[:detail])
    # this is needed or has_secure_password won't validate the saving of a record
    @detail.password = 'temporary'
    @detail.password_confirmation = 'temporary'
    if @detail.save
      redirect_to @detail, notice: t('details.create.notice')
    else
      render action: "new", warning: t('details.create.warning'), layout: 'admin'
    end
  end

  def update
    @detail = Detail.find(params[:id])
    if @detail.update_attributes(params[:detail])
      redirect_to @detail, notice: t('details.update.notice')
    else
      render action: "edit", warning: t('details.update.warning'), layout: 'admin'
    end
  end

  def destroy
    @detail = Detail.find(params[:id])
    if @detail.destroy
      redirect_to users_path, notice: t('details.destroy.notice')
    else
      redirect_to users_path, warning: t('details.destroy.warning')
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tkh_mailing_list-0.0.2 app/controllers/details_controller.rb