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
vivus has quit [Quit: Leaving]
feepbot has quit [Ping timeout: 240 seconds]
feepbot has joined #amber
<FromGitter> <ZeroPointEnergy> I try to find a clever way to do the nil checking when using nested resources so I don't have to repeat the check in ever controller method. This is the only working way I have come up with so far: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ how horrible is this? Is there an obvious easier way I somehow missed? [https://gitter.im/amberframework/amber?at=5b44b53ebd92d80782a369ee]
<FromGitter> <Blacksmoke16> are you using granite?
<FromGitter> <ZeroPointEnergy> yes
<FromGitter> <robacarp> @ZeroPointEnergy that's an interesting strategy.
<FromGitter> <robacarp> My current_user method returns a user which is marked as a guest, so it's never nil.
<FromGitter> <robacarp> doing that would simplify your complexity by an order
<FromGitter> <robacarp> given that, your controller methods would probably look pretty ordinary?
<FromGitter> <robacarp> There is a fair amount of repeated code in my controllers though. In my Domain controller, I have this snippet in each method: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b44c13560c38707836d610a]
<FromGitter> <robacarp> then I do whatever needs done after that.
<FromGitter> <robacarp> this is where I think rails-ish style starts to fall apart with crystal, and where amber could use some better tooling to aid with this stuff
<FromGitter> <robacarp> in Rails, you'd do a before_action method, which could work here as well, but the way Amber handles before_actions can be limiting
<FromGitter> <ZeroPointEnergy> Yeah, it is quite tricky to do it in a way that the compiler accepts it can't be nil. This is interesting: `return redirect_to` maybe this is why my other strategies did not work, I guess redirect_to does not exit the function?
wontruefree has joined #amber
<FromGitter> <Blacksmoke16> one cool thing i did was like
<FromGitter> <Blacksmoke16> (using Kemal tho)
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b44e387e534eb69a5d8316a]
<FromGitter> <Blacksmoke16> then in my controller i can do like
<FromGitter> <Blacksmoke16> `model = resolve params["id"], Domain`
<FromGitter> <Blacksmoke16> in your case could be instead of throw 404 error, do the flash and redirect
<FromGitter> <Blacksmoke16> if `domains_path` is always like model name _path could do like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5b44e4aa3572e970c1860993]
<FromGitter> <Blacksmoke16> or something like that
vivus has joined #amber
wontruefree has quit [Quit: bye]
marenz has joined #amber
<FromGitter> <robacarp> @ZeroPointEnergy yeah, return redirect is a hack. Amber will exit the function on redirect but there’s no way to tell Crystal that without an explicit return.
<FromGitter> <robacarp> @Blacksmoke16 yeah, domains_path is just a string that matches my route, like in rails but manually made. I have a module I include into applicationcontroller which has a method for each route in my application.
wontruefree has joined #amber
<FromGitter> <Prutheus> How can I get the client IP address in a SPA where amber is my api server? Amber needs to get the ip
wontruefree has quit [Ping timeout: 260 seconds]
wontruefree has joined #amber
<FromGitter> <Blacksmoke16> ah gotcha
<FromGitter> <Blacksmoke16> im pretty sure someone answered that before
<FromGitter> <Prutheus> I forgot the answer ...
<FromGitter> <Blacksmoke16> unless someone has a diff answer
<FromGitter> <Prutheus> but why are no request headers passed to amber?
<FromGitter> <Blacksmoke16> they should be, im not sure if they include the ip tho
<FromGitter> <Prutheus> no, but in rails they do or not?
<FromGitter> <Blacksmoke16> im not sure
<FromGitter> <Prutheus> oh man i just wanna get the ip and have no possibility to obtain it
<FromGitter> <Blacksmoke16> :(
<FromGitter> <Prutheus> i mean if i put it behind a nginx proxy, the function request.client_ip still does not exists or?
<FromGitter> <Blacksmoke16> im not sure
<FromGitter> <Blacksmoke16> never dealt with that kind of stuff before
<FromGitter> <Prutheus> hm ... but catching ip of users is very important ...
<FromGitter> <Blacksmoke16> do some Googleing and see what you can find?
<FromGitter> <Prutheus> cant find anything
marenz has quit [Ping timeout: 244 seconds]
<FromGitter> <Blacksmoke16> :/
vivus has quit [Quit: Leaving]
hightower2 has quit [Ping timeout: 255 seconds]
<robacarp> recording the ip address of users is a pretty unreliable way to identify users
<robacarp> if you want to get it in client side, I'd just hit a service like https://api.ipify.org/?format=json
<robacarp> looking at the crystal request object, it doesn't yet have any component which makes the client ip address available
<robacarp> if you're deployed behind nginx, haproxy, an AWS ELB or something, you'll get a request header with the client address
wontruefree has quit [Quit: bye]