The Crystal programming language | http://crystal-lang.org | Fund Crystal's development: http://is.gd/X7PRtI | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/
Syntax error in src/toped.cr:8: expecting token '=>', not 'val'
STATIC_VAR = {"key":"val","key":"val"}
%()
%[]
and %<>
are other string separators
I need help, very beginner here. I am using Crecto, look my Repo.cr
module Repo
extend Crecto::Repo
config do |conf|
conf.adapter = Crecto::Adapters::Mysql
conf.database = "revistinha"
conf.hostname = "localhost"
conf.username = "root"
conf.password = ""
conf.port = 5432
end
end
Then when I do this, it prints "Trying to insert" and then freezes forever, don't print nothing neither print an error
c = Consumidor.new
c.nome = "Gabb"
c.sobrenome = "Esperanto"
puts "Trying to insert..."
changeset = Repo.insert(c)
puts changeset.errors
After a few minutes waiting it throws an huge exception:
https://pastebin.com/TetU7nxy
begin # assert for unique fiels
SQLITE.exec "INSERT INTO users VALUES (?, ?, ?, ?)", SecureRandom.uuid, username, email, password
rescue
message = "Field already taken"
render "views/register.ecr"
else
env.redirect "/"
end
res = SQLITE.query_one?("SELECT id, username, email, password FROM users WHERE username = ?", username, as: {String, String, String, String})
if !res || res.last != password
message = "Invalid username or password"
render "views/login.ecr"
else
user = to_json({"id", "username", "email", "password"}, res)
env.session.string("user", user)
env.redirect("/")
end