<commit_before>#encoding: utf-8
require 'rubygems'
require 'sinatra'
require 'sinatra/reloader'
require 'sinatra/activerecord'

set :database, "sqlite3:lepra.db"

class Post < ActiveRecord::Base
end

get '/' do
	@posts = Post.all
	erb :index		
end

get '/new' do
	erb :new
end

post '/new' do
	p = Post.new params[:post]
	p.save
	erb :new
end<commit_msg>add validates<commit_after>#encoding: utf-8
require 'rubygems'
require 'sinatra'
require 'sinatra/reloader'
require 'sinatra/activerecord'

set :database, "sqlite3:lepra.db"

class Post < ActiveRecord::Base
	validates :name, presence: true
	validates :content, presence: true
end

get '/' do
	@posts = Post.all
	erb :index		
end

get '/new' do
	erb :new
end

post '/new' do
	p = Post.new params[:post]	
	if p.save
		erb "<h2>Thank you!</h2>"
	else
		@error = p.errors.full_messages.first
		erb :new
	end
end
{'fraction_non_alphanumeric': 0.1289198606271777, 'fraction_numerical': 0.006968641114982578, 'mean_word_length': 4.224242424242425, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '383724', 'n_tokens_mistral': 353, 'n_tokens_neox': 343, 'n_words': 96}