Sha256: 888e18a7e9952da691b784d444983ffbd957eeb083b16b928e546319eaf5e81d

Contents?: true

Size: 497 Bytes

Versions: 2

Compression:

Stored size: 497 Bytes

Contents

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

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

    view_builder.build(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.1.3 examples/basic_todo/app/controller_actions/todos_controller/edit.rb
aldous-1.1.2 examples/basic_todo/app/controller_actions/todos_controller/edit.rb