<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> 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> 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