Sha256: 7d8144be2ab6100a697e7d4601576d1bf451998c640c4fda26ce02f1146a45c6

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 Bytes

Contents

class TodosController::Create < 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(Defaults::BadRequestView, errors: [todo_params.error_message]) unless todo_params.fetch

    if todo.save
      view_builder.build(Todos::IndexRedirect)
    else
      view_builder.build(Todos::NewView)
    end
  end

  private

  def todo
    @todo ||= Todo.new(todo_params.fetch)
  end

  def todo_params
    TodosController::TodoParams.build(params)
  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/create.rb
aldous-1.1.2 examples/basic_todo/app/controller_actions/todos_controller/create.rb