UPDATE: April 22, 2019 for Athena version 0.6.0
UPDATE: November 24, 2019 for Athena version 0.7.0 and Crystal 0.31.1
UPDATE: February 7, 2020 for ...
For further actions, you may consider blocking this person and/or reporting abuse
I tried following this tutorial to learn about crystal and api. I am newbie programmer btw.
Following the steps manually and cloning the github source yield the same error:
In src/blog.cr:2:1
2 | Granite::Adapters << Granite::Adapter::Pg.new({name: "my_blog", url: "postgres://dbadmin:password@localhost:5432/blog?currentSchema=blog"})
----------------
Error: undefined constant Granite::Adapters
Did you mean 'Granite::Adapter'?
can you please help what I am doing wrong?
This is a result of some breaking changes that happened in the new Granite version. See github.com/amberframework/granite/...
I'll update the guide to reflect those changes.
Thank you! Looking forward to the update
Should be good to go now, let me know if you run into any trouble.
tried the source again from the repo, new error:
Athena::Routing::Converters::Athena::Routing::Converters::RequestBody(Blog::Models::Article, Nil).new.convert val
--------------------------------------------------------------------
Error: undefined constant Athena::Routing::Converters::Athena::Routing::Converters::RequestBody
I'm still figuring out the problem just would like to let you know.
Make sure you do a
shards update
I updated some dependencies and pinned the versions so it'll always use the correct version.tried again with the shards update. I still couldn't figure out. sorry, I am new to programming, I am a business analyst, and was thinking I could grow with crystal as my realy programming language that's why I am trying to learn it.
@routes.add "/POST/user", RouteAction(
what's the actual error you're getting? Should be towards the very bottom.
I ran through the tutorial on crystal
0.31.1
and everything was fine, so also make sure that's up to date.`wilbert@wilbert-UX360CAK:~/Documents/Development/crystal/athena-blog-tutorial$ crystal ./src/blog.cr
Showing last frame. Use --error-trace for full trace.
There was a problem expanding macro 'macro_140521444230352'
Code in lib/athena/src/routing/handlers/route_handler.cr:19:7
19 | {% for klass in Athena::Routing::Controller.all_subclasses %}
^
Called macro defined in lib/athena/src/routing/handlers/route_handler.cr:19:7
19 | {% for klass in Athena::Routing::Controller.all_subclasses %}
Which expanded to:
Ahhh I figured it out. Apparently
shards update
doesn't actually update the directory in./lib
, thus my version locally was still using the older Athena version. I'll push a fix right now.that's great! thank you very much. I will check in a bit and clone the project again.
I really appreciate your help
Code is now running, just noticed:
After cloning, user must create the logs/development.log directory and file. The code will look for it and will not compile it does not exist.
Was not yet able to find the problem when send post request to localhost:8888/user, error in logs is:
[2019-11-25T05:37:51.194843000Z] main.CRITICAL: Unhandled exception: relation "users" does not exist in Blog::Controllers::UserController at src/controllers/user_controller.cr:6:107 {"cause":null,"cause_class":"Nil"}
I will try later to figure this out
Thanks, I pushed a fix for #1. The other error would be because Granite can't find a table called
users
in the database you're connected to. Be sure you ran the few SQL scripts I've included if you're using PG. Otherwise, be sure you create tables in your DB of choice.