faustinoaq changed the topic of #amber to: Welcome to Amber Framework community! | https://amberframework.org | Developer happiness, productivity and bare metal performance | GH: https://github.com/amberframework | Docs: https://docs.amberframework.org | Gitter: https://gitter.im/amberframework/amber | IRC Logger: https://irclog.whitequark.org/amber | Amber::Server.start
feepbot has quit [Ping timeout: 240 seconds]
feepbot has joined #amber
wontruef_ has quit [Ping timeout: 265 seconds]
wontruefree has joined #amber
<FromGitter> <AizuddinBadry> ``````
<FromGitter> <AizuddinBadry> I got this error. cant get my amber apps working. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b399fb760c3870783556b88]
wontruefree has quit [Quit: bye]
<FromGitter> <sam0x17> you probably ran shards install as root and now you don't have permission to open some of the files it created
<FromGitter> <sam0x17> I think if you `rm -rf /Users/aizuddinbadry/.cache/shards/` and run `shards install` again it should fix it
<FromGitter> <sam0x17> you would probably have to put sudo before the rm rf
<FromGitter> <AizuddinBadry> Thanks @sam0x17 for your reply
<FromGitter> <AizuddinBadry> i try it now
wontruefree has joined #amber
wontruefree has quit [Quit: bye]
feepbot has quit [Ping timeout: 260 seconds]
feepbot has joined #amber
<FromGitter> <Prutheus> how to add a column to a model which already exists?
<FromGitter> <Prutheus> in RubyOnRails, I can create a migration for that with a special name via the command line, is that also possible for amber?
<FromGitter> <waghanza> @Prutheus what orm are you using `jenifer`, `granite` or `crecto`
<FromGitter> <waghanza> The database migrations are not done the same way
<FromGitter> <Prutheus> granite
<FromGitter> <waghanza> so it's pure sql script
<FromGitter> <waghanza> see link above
<FromGitter> <Blacksmoke16> correct
<FromGitter> <vishalsodani> @valamorgon Yes. src/models/user.cr
<FromGitter> <Prutheus> I am using granite. How to specify an auto-increment to my id field so it counts up automatically and I do not need to give the entry i create explicitly an id?
wontruefree has joined #amber
<FromGitter> <Blacksmoke16> when doing a migration?
<FromGitter> <Blacksmoke16> if you dont specify a `primary` field on your model granite assumes there is a `id BIGINT AUTO_INCREMENT PRIMARY KEY`
<FromGitter> <Blacksmoke16> @Prutheus
<FromGitter> <Blacksmoke16> (or the adapter equivalent, that is for mysql)
<FromGitter> <Blacksmoke16> ofc you actually have to *create* that column in your migration
<FromGitter> <Prutheus> I have that migration https://bpaste.net/show/99dc77d5f5a0 and this seed https://bpaste.net/show/476df1503685 . ... but my user gets no ip when calling `amber db seed`
<FromGitter> <Blacksmoke16> ip or id?
<FromGitter> <Blacksmoke16> what does the model look like?
wontruefree has quit [Quit: this is not the client you are looking for]
wontruefree has joined #amber
wontruefree has quit [Client Quit]
wontruefree has joined #amber
<FromGitter> <Blacksmoke16> im thinking its saving correctly but granite doesnt know what id it was given, i.e. if you did a like `User.find_by(email: "mail@mail.com")`it would include an id
<FromGitter> <Prutheus> no, in my sqlite browser it does not contain an id
<FromGitter> <Prutheus> i mean id, id is missing
<FromGitter> <Blacksmoke16> from the actual table?
<FromGitter> <Blacksmoke16> ah like it gets inserted but id column is null
<FromGitter> <Prutheus> yes
<FromGitter> <Blacksmoke16> so you are using sqlite yes?
<FromGitter> <Blacksmoke16> BIGSERIAL is for postgres afaik
<FromGitter> <Blacksmoke16> for sqlite it would just be `id INTEGER PRIMARY KEY`
<FromGitter> <Prutheus> yeah i created my aber project with -d sqlite3 . .... but for some reason it still generates all with pg
<FromGitter> <Blacksmoke16> :thinking:
<FromGitter> <Blacksmoke16> that might be a bug then
<FromGitter> <Prutheus> yeah
<FromGitter> <Blacksmoke16> not a bug
<FromGitter> <Blacksmoke16> ` string ["-d", "--database"], desc: "# Preconfigure for selected database. Options: pg | mysql | sqlite", default: "pg"`
<FromGitter> <Blacksmoke16> sqlite3 isnt valid option so defaulted to pg
<FromGitter> <Prutheus> wow but amber --help says sqlite3
<FromGitter> <Prutheus> oh no
<FromGitter> <Prutheus> i am wrong, sorry
<FromGitter> <Prutheus> where can i change that now in my existing proejct?
<FromGitter> <Blacksmoke16> im not sure
<FromGitter> <Blacksmoke16> what that command all does to know what to change
<FromGitter> <Prutheus> so i should create my project new? ...
<FromGitter> <Blacksmoke16> i dont know. I dont use amber so not really sure
<FromGitter> <drujensen> try `.amber.yml`
<FromGitter> <Prutheus> thanks
<FromGitter> <Prutheus> an other question ... how to access the routes which are defined in `routes :api do` ?
<FromGitter> <Prutheus> via localhost:3000/apicall . i can't access it
<FromGitter> <drujensen> what is the definition look like?
<FromGitter> <drujensen> you should be able to access `http://localhost:3000/posts` ⏎ ⏎ ``` routes :api do ⏎ resources "/posts", PostController ⏎ end``` [https://gitter.im/amberframework/amber?at=5b3a6de770efc60660a70233]
<FromGitter> <Prutheus> I get 403 Forbidden for invalid origins, methods or headers
<FromGitter> <Blacksmoke16> if you accessing it from JS prob have to enable/setup cors
<FromGitter> <Prutheus> what have i to enable?
<FromGitter> <Blacksmoke16> is a security measure
<FromGitter> <Prutheus> ok but i access it via the same machine ... why is it restricted, how to configure it to allow it?
<FromGitter> <Blacksmoke16> im just guessing that this is your issue
<FromGitter> <Prutheus> so i should remove cors from the pipeline of the api?
<FromGitter> <Prutheus> or should i directly write my get routes in the :web instead of :api?
<FromGitter> <Prutheus> When I remove the cors pipe, it works ....
<FromGitter> <Prutheus> but i thought the :api route is for api stuff ... what to do now?
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <Prutheus> remove cors pipe or put all my get routes in the :web route?
<FromGitter> <Blacksmoke16> how is your app setup? like are you using a front end JS library or something to get your data or is it more standard rails like where your pages are rendered by amber?
<FromGitter> <Prutheus> frontend js
<FromGitter> <Prutheus> my amber app should just be the websocket/json api server
<FromGitter> <Blacksmoke16> then you'll need the cors most likely, otherwise you'd get the `No 'Access-Control-Allow-Origin' header is present on the requested resource.` error when going to fetch the data in your JS
<FromGitter> <Blacksmoke16> but if you have it working i wouldnt worry about it
<FromGitter> <Prutheus> it does not work with the cors pipe loaded
<FromGitter> <Prutheus> 403 then
<FromGitter> <Blacksmoke16> dunno, could be more going on than just cor issue then
<FromGitter> <Prutheus> no, when i remove the cors pipe from the :api route, it works
<FromGitter> <Blacksmoke16> alright then
<FromGitter> <Prutheus> so i should take it out?
<FromGitter> <Blacksmoke16> for now i guess
<FromGitter> <Blacksmoke16> want want to see if you can figure out why it 403s later but for now its prob fine
<FromGitter> <Prutheus> ok thanks
<FromGitter> <Prutheus> why does this results in an error: ```wrong number of arguments for 'User.find_by' (given 2, expected 0) ⏎ Overloads are: ⏎ ⏎ 1) Granite::Querying#find_by(**args) ⏎ ... [https://gitter.im/amberframework/amber?at=5b3a7b0689db5e701c9bef81]
<FromGitter> <Prutheus> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b3a7b2933b0282df4fa3b90]
<FromGitter> <paulcsmith> It's expecting **args, which means it is expecting a NamedTuple of arguments. So in this case it would be `User.find_by(email: params["email"])`
<FromGitter> <Prutheus> thanks
<FromGitter> <paulcsmith> You're welcome
<FromGitter> <Prutheus> does somebody know how i can obtain the ip of the client who has requested a directive ?
<FromGitter> <fridgerator> In a controller I think you can use `request.client_ip`, but I think this only works behind a proxy (like nginx)
<FromGitter> <Prutheus> this method is undefined ... is there is also a way without a proxy?
wontruefree has quit [Quit: this is not the client you are looking for]
wontruefree has joined #amber
<FromGitter> <Prutheus> @Blacksmoke16 you remember i want to build a amber api server for my js frontend? .... i want to realize a login, when logged in, i want to use a cookie for that, can i create that cookie in amber to manage the sign_in status in the api calls or must i do it different?
<FromGitter> <Blacksmoke16> thats one way to do it yes
<FromGitter> <Blacksmoke16> JWT is also popular
<FromGitter> <waghanza> `jwt` is useful for server-to-server encryption
<FromGitter> <waghanza> using it for client-to-server is a `nightmare`
<FromGitter> <fridgerator> how?
<FromGitter> <waghanza> to use `jwt` ?
<FromGitter> <fridgerator> yeah
<FromGitter> <waghanza> to time / resource consuming on client-side
<FromGitter> <waghanza> `jwt` is more *accurate* to use from a `node` (or any frontend server, not client side) to an `api`
<FromGitter> <fridgerator> if you're using it in a javascript client, all you're doing it storing it and using it as an auth token
<FromGitter> <waghanza> yep + resource consumption + having to generate `jwt` token
<FromGitter> <fridgerator> but its not generated on the client side
<FromGitter> <waghanza> i've read https://developer.okta.com/blog/2017/08/17/why-jwts-suck-as-session-tokens and I'm conviced
<FromGitter> <waghanza> no it's stored client-side + having to generate (have logic for it) on server side
<FromGitter> <waghanza> I have implemented it but quickly stopped having implement from client-side to server-side
<FromGitter> <waghanza> but I'm still using it from frontend server to my back api
<FromGitter> <Prutheus> i also wanna use it, it seems to be awesome
<FromGitter> <fridgerator> well I dissagree, I've used it and have not had any issues
<FromGitter> <waghanza> I do not say that `jwt` *COULD* not be used like that, but I do not recommand + it was not made for that
<FromGitter> <waghanza> session is enough
<FromGitter> <fridgerator> using session with SPA's is hard
<FromGitter> <waghanza> session from client-side to frontend-server and front-end to backend with `jwt`
<FromGitter> <waghanza> @fridgerator sure. that's why I'm not using `SPA`
<FromGitter> <fridgerator> you may not be, but @Prutheus is
<FromGitter> <Prutheus> I think JWT is perfect for generating a token on the signin at the server and then handle it at all requests to the servers member area api calls
<FromGitter> <waghanza> @fridgerator I use `SSR`
<FromGitter> <waghanza> @fridgerator I do use `SPA` (at least for my *production*) as I have to deal with some old browsers / desktop / customers / mobiles
<FromGitter> <Prutheus> what is ssr?
<FromGitter> <Blacksmoke16> prob server side rendering ?
<FromGitter> <waghanza> yep
<FromGitter> <Blacksmoke16> like what rails/amber does
<FromGitter> <Blacksmoke16> when not using it as api
<FromGitter> <waghanza> @Blacksmoke16 https://nuxtjs.org/ (at least for `vuejs`)
<FromGitter> <Prutheus> but this is old and not modern anymore?
<FromGitter> <waghanza> `ssr` let use rendering on both `client-side` and `server-side`
<FromGitter> <waghanza> kind of ajax
<FromGitter> <Blacksmoke16> imo whatever you use its prob fine
<FromGitter> <waghanza> sure
<FromGitter> <Blacksmoke16> only going to be an issue if it gets super big
<FromGitter> <waghanza> just a *recommandation*, I do not have universal science
<FromGitter> <Blacksmoke16> i like the concept of JWT, just makes more sense than sessionId
<FromGitter> <Blacksmoke16> server creates it on login, sets cookie, have my angular send it with each request to api
<FromGitter> <Blacksmoke16> can store roles/metadata in it and such
<FromGitter> <waghanza> sure, it's a usage, and personnaly I'm not keen on ⏎ btw, `jwt`was not made for that, but could be used as that
<FromGitter> <waghanza> `jwt` is just an encryption library
<FromGitter> <waghanza> for me too consuming on `client-side` (but it depends on use case)
<FromGitter> <Blacksmoke16> mhm
<FromGitter> <waghanza> thus I do not try to use `jwt` on `react native`
<FromGitter> <waghanza> 😜