Sha256: 3516f06363a1f75ed17c8bf74bbdd581f657bc1dbe717dcb0d881766fea5fbfe

Contents?: true

Size: 492 Bytes

Versions: 2

Compression:

Stored size: 492 Bytes

Contents

class TodosController::Destroy < BaseAction
  def default_view_data
    super.merge({todo: todo})
  end

  def perform
    return build_view(Home::ShowRedirect) unless current_user
    return build_view(Todos::NotFoundView, todo_id: params[:id]) unless todo
    return build_view(Defaults::ForbiddenView) unless current_ability.can?(:destroy, todo)

    todo.destroy

    build_view(Todos::IndexRedirect)
  end

  private

  def todo
    @todo ||= Todo.where(id: params[:id]).first
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aldous-1.0.1 examples/basic_todo/app/controller_actions/todos_controller/destroy.rb
aldous-1.0.0 examples/basic_todo/app/controller_actions/todos_controller/destroy.rb