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
<FromGitter> <sam0x17> anyone have a neat redirect-http-to-https thing I can throw in as a before filter or routing rule in amber?
<FromGitter> <Blacksmoke16> no easier to use nginx or something?
<FromGitter> <sam0x17> somewhere in the chain there actually is nginx but I have no idea how to get at it's configuration as I'm behind docker elastic beanstalk
<FromGitter> <sam0x17> in rails it's just `config.force_ssl = true`
<FromGitter> <ninjapanzer> Morning, wanted to support the project monetarily but saw this over on librepay `Cannot be renewed because the account of the recipient isn't ready to receive new payments.`
<robacarp> @sam0x17 if you're using aws, just do it on the elb
<robacarp> the elb is free when it's attached to something, and you can do 301s there all day
<FromGitter> <sam0x17> yeah you are right
<FromGitter> <sam0x17> @Sija do you have an example of how to set raven.cr to capture errors in amber? Or should it work out of the box if DSN is set
<FromGitter> <sam0x17> I managed to find https://github.com/Sija/raven.cr/blob/master/src/raven/integrations/amber.cr but with it enabled it doesn't seem to be reporting any errors to sentry
<FromGitter> <sam0x17> if I wrap my error in a `Raven.capture` block though it does get reported, so maybe the amber integration needs to be updated
<FromGitter> <sam0x17> does anyone know when `build_request_url` was refactored / removed?
<FromGitter> <drujensen> I don’t recall this feature but you can check pull requests or git to search the history
<FromGitter> <drujensen> Git blame
<FromGitter> <sam0x17> the problem is I'm having trouble finding evidence that it ever existed
<FromGitter> <sam0x17> oh my mistake
<FromGitter> <sam0x17> that's an internal thing in raven
<FromGitter> <sam0x17> need to dig deeper
<FromGitter> <sam0x17> aha! ⏎ had to include the pipe `plug Raven::Amber::Pipe::Error.new`
<FromGitter> <sam0x17> now everything works
<FromGitter> <sam0x17> except I don't get line numbers or file names in my backtraces :(
<FromGitter> <sam0x17> though that's only in production strangely, but I am compiling with --debug
<FromGitter> <drum445> When using the granite orm, why is my id field of type (String | Nil)
<FromGitter> <drum445> It is defined as a non-nillable string `column id : String, primary: true, auto: false`
<FromGitter> <Blacksmoke16> is what the implementation is atm
<FromGitter> <Blacksmoke16> `.id!` is not nilable
<FromGitter> <Blacksmoke16> related: https://github.com/amberframework/granite/pull/370
<FromGitter> <drum445> the primary key is nillable by default?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> because there wont be a PK until its saved
<FromGitter> <drum445> cool, cheers
<FromGitter> <drum445> Granite seems nice so far
<FromGitter> <Blacksmoke16> hence why that PR would be a better implementation
<FromGitter> <Blacksmoke16> versus the magic constructor that gets used behind the scenes
<FromGitter> <Blacksmoke16> If you want to bump that issue feel free, if we're all on board with it i could finish it up
<FromGitter> <drum445> I'm having trouble getting a relationship to work tbh
<FromGitter> <Blacksmoke16> whats the error/code?
<FromGitter> <drum445> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5e9e0d0f74bfed5a1b51db37]
<FromGitter> <drum445> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5e9e0d24d65bcf75b5dab172]
<FromGitter> <drum445> when I do a find_by on user, I get a user object back correctly, but it doesn't have a game array
<FromGitter> <Blacksmoke16> did you call `.game` on it?
<FromGitter> <Blacksmoke16> id do like `has_many :games, class_name: Game`
<FromGitter> <Blacksmoke16> then `user.games`
<FromGitter> <drum445> okay, I get something back `<Granite::AssociationCollection(User, Game)...`
<FromGitter> <drum445> is this an iterable?
<FromGitter> <Blacksmoke16> it lazily executes your query
<FromGitter> <Blacksmoke16> so like `.each` or `.to_a` would execute the query then
<FromGitter> <drum445> ah perfect, that got it
<FromGitter> <drum445> thanks
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <drum445> was this orm library inspired by another one?
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <drum445> what do you call your class names?
<FromGitter> <drum445> `UserRepo` ?
<FromGitter> <Blacksmoke16> `User`
<FromGitter> <drum445> or just `User`
<FromGitter> <Blacksmoke16> i call them what a single row in the database would be
<FromGitter> <Blacksmoke16> `Post` and table `posts`
feepbot has quit [Ping timeout: 264 seconds]
<FromGitter> <drum445> makes sense, cheers. And do you just add normal business logic to those classes, or have them as single purpose for DB interactions?
<FromGitter> <Blacksmoke16> depends on the logic
<FromGitter> <Blacksmoke16> like say you have a `Customer` model that has various fields that determine if that customer is "active"
<FromGitter> <Blacksmoke16> then you could ofc define a like `.active?` method on it to abstract that logic
feepbot has joined #amber
<FromGitter> <Blacksmoke16> but id try to avoid putting too much in there that doesnt exactly fit in
<FromGitter> <Sija> @sam0x17 I’m afraid that missing file names and line numbers are related to compiling with `—production` flag set, see do they get reported when compiled without it
<FromGitter> <drum445> Thanks for your hepl again @Blacksmoke16, think I'll stick with Granite for my Ruby Active Record alternative 👍
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <drum445> another question sorry, is it possible to perform a query in one find_by but across two tables, something like `User.find_by(user_id: user_id, post.category: "test" )`
<FromGitter> <drum445> which would be ⏎ `select * from users inner join posts on posts.user_id = user.id where users.id = '1234' and posts.category = 'test';`
<FromGitter> <drum445> and I'd want a user object to be returned, with one entry in the posts array
<FromGitter> <Blacksmoke16> hm
<FromGitter> <drum445> ```user = User.find!(user_id) ⏎ post = user.posts.find_by!(category: "test")``` [https://gitter.im/amberframework/amber?at=5e9e2277c7dcfc14e2d6c1a1]
<FromGitter> <drum445> that works, but I imagine that will be making two db calls :(
<FromGitter> <Blacksmoke16> this is essentially STI
<FromGitter> <Blacksmoke16> which granite doesnt support atm
<FromGitter> <drum445> STI?
<FromGitter> <Blacksmoke16> single table inheritence
<FromGitter> <drum445> ah
<FromGitter> <Blacksmoke16> in this case tho, might be able to do like `User.first("inner join posts on posts.user_id = user.id where users.id = '1234' and posts.category = 'test'")`
<FromGitter> <Blacksmoke16> no idea if that would work
<FromGitter> <drum445> yeah, that seems to have worked
<FromGitter> <drum445> n1, although as I'm only using a foreign key atm I can just do `Post.find_by!(user_id: user_id, category: "test")`
<FromGitter> <drum445> not really ideal as I want a user object and only works as the post table has user_id, will probably use the explicit SQL for now then, ta
<FromGitter> <Blacksmoke16> if/when STI is enabled, idea is you would have some abstract model that defines common stuff and children for each specific type
<FromGitter> <Blacksmoke16> then you could do like `TestPost.find` which would add a like `type = 'test'` behind the scenes
<FromGitter> <drum445> ah right, that's what activerecord uses I believe