Sha256: ca5c2753ca911f191e927f6a186465bd4b59e4342e482603bd2c519bb235dde9

Contents?: true

Size: 465 Bytes

Versions: 2

Compression:

Stored size: 465 Bytes

Contents

class TodosController::Edit < 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?(:update, todo)

    build_view(Todos::EditView)
  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/edit.rb
aldous-1.0.0 examples/basic_todo/app/controller_actions/todos_controller/edit.rb