Sha256: 3ca2729bca3ce0776d1a3514a515d3d7781a5d15e70093492eae712a7e088b2b
Contents?: true
Size: 755 Bytes
Versions: 2
Compression:
Stored size: 755 Bytes
Contents
class TodosController::Update < BaseAction def default_view_data super.merge({todo: todo}) end def perform return build_view(Home::ShowRedirect) unless current_user return build_view(Defaults::BadRequestView, errors: [todo_params.error_message]) unless todo_params.fetch return build_view(Todos::NotFoundView, todo_id: params[:id]) unless todo return build_view(Defaults::ForbiddenView) unless current_ability.can?(:update, todo) if todo.update_attributes(todo_params.fetch) build_view(Todos::IndexRedirect) else build_view(Todos::EditView) end end private def todo @todo ||= Todo.where(id: params[:id]).first end def todo_params TodosController::TodoParams.build(params) 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/update.rb |
aldous-1.0.0 | examples/basic_todo/app/controller_actions/todos_controller/update.rb |