Sha256: da4620bf302e383b7764e7da0efa5afd09553ce8c72ee7fb01409275620cb104

Contents?: true

Size: 525 Bytes

Versions: 7

Compression:

Stored size: 525 Bytes

Contents

# frozen_string_literal: true

require "sinatra/base"
require "sinatra/reloader"
require "toycol"
require_relative "post"

Toycol::Protocol.use(:safe_ruby_with_sinatra)

class App < Sinatra::Base
  set :server, :toycol
  set :port, 9292

  get "/posts" do
    @posts = params[:user_id] ? Post.where(user_id: params[:user_id]) : Post.all

    erb :index
  end

  post "/posts" do
    Post.new(user_id: params[:user_id], body: params[:body])
    @posts = Post.all

    erb :index
  end

  run! if app_file == $PROGRAM_NAME
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
toycol-1.0.0 examples/safe_ruby_with_sinatra/app.rb
toycol-0.3.1 examples/safe_ruby_with_sinatra/app.rb
toycol-0.3.0 examples/safe_ruby_with_sinatra/app.rb
toycol-0.2.2 examples/safe_ruby_with_sinatra/app.rb
toycol-0.2.1 examples/safe_ruby_with_sinatra/app.rb
toycol-0.2.0 examples/safe_ruby_with_sinatra/app.rb
toycol-0.1.0 examples/safe_ruby_with_sinatra/app.rb