Crystal Language

//Crystal Language

mongo_orm Exception: missing bson key: publish_acl (Exception)

When you extend your field definitions in the mongo_orm document classes, specifically with embedded documents, you might run into the following runtime (!) error:Exception: missing bson key: <name> (Exception)This is not an error in your code – your code is raising, because the database structure is not as it expects it to be!Here’s the sample [...]

By | Mai 10th, 2019|Crystal Language|Kommentare deaktiviert für mongo_orm Exception: missing bson key: publish_acl (Exception)

mongo_orm custom name for collection

mongo_orm will automatically determine the name for your collection by using the Module and Class name, and appending an “s”.In cases where you want to name your collection, you can simply do this:class PapiTest < Mongo::ORM::Document     collection_name "Buster"     field test : String end get "/" do     pt = PapiTest.new     pt.test = "I want your sex"     [...]

By | April 17th, 2019|Crystal Language|Kommentare deaktiviert für mongo_orm custom name for collection

Instructions for adding a user to a mongo database for mongo_orm

You don’t want your web application to access the database using your database admin user. Additionally you want it to access only one specific database – maybe you have additional databases running in your mongo instance. Prerequisites:mongo_orm expects the database configuration as environment variables or as a file config/database.yml in your project.The config/database.yml file looks [...]

By | Februar 9th, 2019|Crystal Language|Kommentare deaktiviert für Instructions for adding a user to a mongo database for mongo_orm

Building a persistent in-line editing experience with Crystal, MongoDB (datanoise / sam0x17)

As documentation is still sparse, I would like to add some.This is what I am building currently:The individual fields are going to be editable with an inline editor, which will automatically save to the backend – no need for reloading the whole page.The point of the whole is a backend for my company, to be [...]

By | Februar 5th, 2019|Crystal Language|Kommentare deaktiviert für Building a persistent in-line editing experience with Crystal, MongoDB (datanoise / sam0x17)

kemal-session does not persist data

https://github.com/kemalcr/kemal-sessionAnalyse what is happening with your session cookie. In my case, the session cookie was reset everytime I went to login. I realized, that my idea of cleaning up the old session as a first statement after successful login, before setting up the new session is not a good idea. I suspect, that the browser [...]

By | Januar 22nd, 2019|Crystal Language|Kommentare deaktiviert für kemal-session does not persist data

Using modules in crystal

As your application grows, you would like to move from one big .cr file to separating your code into smaller files.You can use require from your main .cr file to add code from other files:require "./tools/*"This statement will add code from the tools directory, relative to your main .cr file.This will help to separate your [...]

By | Januar 22nd, 2019|Crystal Language|Kommentare deaktiviert für Using modules in crystal

The scope of ecr within crystal: or how do I pass in variables and Objects into ECR templates?

As a beginner in the Crystal language I still struggle to get my head around some of the concepts in it, and develop a feel for coding in Crystal.When I come across difficult problems, which I solve or start to understand, I blog about them, so others can benefit – as lack of documentation is [...]

By | Januar 21st, 2019|Crystal Language|Kommentare deaktiviert für The scope of ecr within crystal: or how do I pass in variables and Objects into ECR templates?

Exception: Unexpected quote at 1:2 (CSV::MalformedCSVError) Crystal

While trying to parse an Amazon pay file, I stumbled across this particular problem:Exception: Unexpected quote at 1:2 (CSV::MalformedCSVError)The reason: Amazon Pay encodes it’s files in UTF-8 with BOM. The BOM is an optional (in UTF-8 files) marker. You can see it with the tool xxd for instancexxd apolish_amazon_2018DecMonthlyTransaction.csv | lessThe three dots at the [...]

By | Januar 13th, 2019|Crystal Language|Kommentare deaktiviert für Exception: Unexpected quote at 1:2 (CSV::MalformedCSVError) Crystal

Install Crystal on Docker: how to add the Crystal repository to Docker in the Dockerfile

Dockerfile (excerpt)ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn RUN apt-get update && apt-get install -y \          software-properties-common \          build-essential \         libevent-dev \         libssl-dev \         libxml2-dev \         libyaml-dev \         libgmp-dev \         libreadline-dev \         apt-transport-https \         iputils-ping \         git \         aptitude \         nano \         openssh-server \         && apt-key adv --keyserver keys.gnupg.net --recv-keys 09617FD37CC06B54 \         && add-apt-repository 'deb https://dist.crystal-lang.org/apt crystal main' [...]

By | Januar 11th, 2019|Crystal Language, Docker|Kommentare deaktiviert für Install Crystal on Docker: how to add the Crystal repository to Docker in the Dockerfile

Crystal libevent-2.0.so.5: cannot open shared object file

Today I upgraded my Ubuntu to 18.04.Compiling a file with Crystal gives me the following error:stderr:     /root/.cache/crystal/usr-share-crystal-src-ecr-process.cr/macro_run: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directoryThe library in question, libevent-2.0.so.5 has been superseded by libevent-2.1.so.6 => /usr/lib/x86_64-linux-gnu/libevent-2.1.so.6 Crystal is of course aware of this and will link [...]

By | Januar 5th, 2019|Crystal Language, Development|Kommentare deaktiviert für Crystal libevent-2.0.so.5: cannot open shared object file