Sha256: 4d6a41169e695b5b84a4a69679aebaeafe8edd79e4aadbc4e966f650cbb82df9

Contents?: true

Size: 811 Bytes

Versions: 13

Compression:

Stored size: 811 Bytes

Contents

module TodoList
  class Tasks < Controller
    map '/'

    def index
      @tasks = Task.all
      @title = request[:title]
    end

    def create
      if request.post? and title = request[:title]
        title.strip!

        unless title.empty?
          Task.create :title => title
        end
      end

      redirect route('/', :title => title)
    rescue Sequel::DatabaseError => ex
      redirect route('/', :title => title)
    end

    def open(title)
      Task[:title => Ramaze::Helper::CGI.url_decode(title)].open!
      redirect r('/')
    end

    def close(title)
      Task[:title => Ramaze::Helper::CGI.url_decode(title)].close!
      redirect r('/')
    end

    def delete(title)
      Task[:title => Ramaze::Helper::CGI.url_decode(title)].destroy
      redirect r('/')
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ramaze-2023.01.06 examples/app/todolist/controller/task.rb
ramaze-2012.12.08 examples/app/todolist/controller/task.rb
ramaze-2012.12.08b examples/app/todolist/controller/task.rb
ramaze-2012.04.14 examples/app/todolist/controller/task.rb
ramaze-2012.03.07 examples/app/todolist/controller/task.rb
ramaze-2011.12.28 examples/app/todolist/controller/task.rb
ramaze-2011.10.23 examples/app/todolist/controller/task.rb
ramaze-2011.07.25 examples/app/todolist/controller/task.rb
ramaze-2011.01.30 examples/app/todolist/controller/task.rb
ramaze-2011.01 examples/app/todolist/controller/task.rb
ramaze-2010.06.18 examples/app/todolist/controller/task.rb
ramaze-2010.04.04 examples/app/todolist/controller/task.rb
ramaze-2010.04 examples/app/todolist/controller/task.rb