jhass[m] changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.1.2, 3.0.4, 2.7.6: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://goo.gl/wpGhoQ
Rounin has quit [Ping timeout: 248 seconds]
Guimauve has quit [Ping timeout: 250 seconds]
grokify has joined #ruby
crux73 has joined #ruby
cartdrige has quit [Ping timeout: 264 seconds]
grokify has quit [Ping timeout: 260 seconds]
toshiba__ has joined #ruby
crux73 has quit [Ping timeout: 250 seconds]
cartdrige has joined #ruby
markong has quit [Ping timeout: 260 seconds]
toshiba__ has quit [Ping timeout: 248 seconds]
hellstabber has quit [Quit: Connection closed for inactivity]
<sam113101> so how do you initialize a singleton?
<weaksauce> generally avoid singletons
reset has quit [Quit: reset]
reset has joined #ruby
<adam12> Na_Klar: I don't think so. I believe ko1 has a few gems that do similar things; maybe there's something hidden in one of them? https://github.com/ko1/yomikomu
<adam12> staff420: I'd probably give it a name and encapsulate it. Coin.toss or something :P Seems like a contrived example.
<adam12> Coin.toss do |landing| landing.heads { puts "Hello Head World!" }; landing.tails { puts "Nope" }; end;
Guimauve has joined #ruby
Nowaker has quit [Ping timeout: 248 seconds]
Nowaker has joined #ruby
John_Ivan has quit [Ping timeout: 248 seconds]
nirvdrum has joined #ruby
<Na_Klar> adam12: thx
mikecmpbll has joined #ruby
hellstabber has joined #ruby
mikecmpbll has quit [Ping timeout: 268 seconds]
mitt3ns has left #ruby [#ruby]
some14u has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guimauve has quit [Quit: Ping timeout (120 seconds)]
Guimauve has joined #ruby
Na_Klar has left #ruby [https://quassel-irc.org - Komfortabler Chat. Überall. ]
nirvdrum has quit [Quit: nirvdrum]
grokify has joined #ruby
grokify has quit [Ping timeout: 248 seconds]
croot has joined #ruby
<croot> This is so harsh when we get no error at all.
<croot> I'm not very useful with test
<croot> I should write something like: is_rich_text_content_showing(false, "should assert true")
<croot> when I run db:create db:migrate db:seed it shows all table created
<croot> except for production database but I'm not using it at the moment.
<croot> I followed the tutorial on https://rubyonrails.org at first it showed the rich_text_area then, I tried to git push several migration, rvm upgrade to 3.1.2 etc.
<croot> I ran rails action_text:install
<croot> I use postgresql on a local machine.
<croot> I ran rails db:system:change --to=postgresql on my local machine if that helps.
rhe has quit [Ping timeout: 268 seconds]
RougeR has quit [Ping timeout: 250 seconds]
<croot> That's where i'm leading at right now
nirvdrum has joined #ruby
rhe has joined #ruby
rhe has quit [Ping timeout: 248 seconds]
desnudopenguino1 has joined #ruby
<croot> I've ran into rails assets:precompile and got this : Sprockets::DoubleLinkError: Multiple files with the same output path cannot be linked ("actiontext.css")
desnudopenguino has quit [Ping timeout: 248 seconds]
desnudopenguino1 is now known as desnudopenguino
nirvdrum has quit [Quit: nirvdrum]
crux73 has joined #ruby
<croot> fastforward to test-unit, perhaps somebody can help me out with this behavior
cartdrige has quit [Ping timeout: 268 seconds]
grokify has joined #ruby
hellstabber has quit [Quit: Connection closed for inactivity]
grokify has quit [Ping timeout: 260 seconds]
crux73 has quit [Ping timeout: 252 seconds]
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
croot has quit [Quit: ZZZzzz…]
desnudopenguino has quit [*.net *.split]
reset has quit [*.net *.split]
howdoi has quit [*.net *.split]
Vaevictus has quit [*.net *.split]
dviola has quit [*.net *.split]
Milos has quit [*.net *.split]
Inoperable has quit [*.net *.split]
jetchisel has quit [*.net *.split]
clemens3 has quit [*.net *.split]
mahler has quit [*.net *.split]
legahc has quit [*.net *.split]
kaivai has quit [*.net *.split]
thomas25 has quit [*.net *.split]
sam113101 has quit [*.net *.split]
wnd has quit [*.net *.split]
jtperreault has quit [*.net *.split]
georgemp has quit [*.net *.split]
balo has quit [*.net *.split]
wnd has joined #ruby
legahc has joined #ruby
jetchisel has joined #ruby
Vaevictus has joined #ruby
sam113101 has joined #ruby
howdoi has joined #ruby
dviola has joined #ruby
desnudopenguino has joined #ruby
jetchisel has joined #ruby
jetchisel has quit [Signing in (jetchisel)]
jtperreault has joined #ruby
georgemp has joined #ruby
clemens3 has joined #ruby
kaivai has joined #ruby
Milos has joined #ruby
hasley has joined #ruby
balo has joined #ruby
Inoperable has joined #ruby
nirvdrum has joined #ruby
thomas25 has joined #ruby
ur5us_ has quit [Ping timeout: 248 seconds]
D_A_N has quit [Quit: leaving]
nirvdrum has quit [Quit: nirvdrum]
ur5us has joined #ruby
nirvdrum has joined #ruby
Guimauve is now known as Guimauve|AFK
Furai has quit [Quit: WeeChat 3.7]
Furai has joined #ruby
CrazyEddy has quit [Ping timeout: 260 seconds]
dviola has left #ruby [WeeChat 3.7]
dviola has joined #ruby
teclator has joined #ruby
ur5us has quit [Ping timeout: 246 seconds]
hightower2 has quit [Remote host closed the connection]
nirvdrum has quit [Quit: nirvdrum]
wand has quit [Ping timeout: 258 seconds]
wand has joined #ruby
jdmark has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
rvalue has quit [Ping timeout: 268 seconds]
jdmark has joined #ruby
wand has quit [Ping timeout: 258 seconds]
mikecmpbll has joined #ruby
rvalue has joined #ruby
mikecmpbll has quit [Ping timeout: 264 seconds]
rvalue has quit [Ping timeout: 264 seconds]
wand has joined #ruby
dionysus69 has joined #ruby
Rounin has joined #ruby
Rounin has quit [Changing host]
Rounin has joined #ruby
ur5us has joined #ruby
r3m has quit [Quit: WeeChat 3.8-dev]
Guimauve|AFK has quit [Quit: Ping timeout (120 seconds)]
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
r3m has joined #ruby
grokify has joined #ruby
otisolsen70 has joined #ruby
grokify has quit [Ping timeout: 260 seconds]
grokify has joined #ruby
jvalleroy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
jvalleroy has joined #ruby
Guimauve|AFK has joined #ruby
Guimauve|AFK has quit [Client Quit]
Guimauve|AFK has joined #ruby
teclator has quit [Ping timeout: 252 seconds]
rvalue has joined #ruby
teclator has joined #ruby
royo25 has joined #ruby
jpn has quit [Ping timeout: 268 seconds]
ur5us has quit [Ping timeout: 260 seconds]
jpn has joined #ruby
croot has joined #ruby
croot has quit [Client Quit]
howdoi has quit [Quit: Connection closed for inactivity]
walez has joined #ruby
walez___ has joined #ruby
walez has quit [Ping timeout: 260 seconds]
Guimauve|AFK has quit [Ping timeout: 264 seconds]
Guimauve|AFK has joined #ruby
finsternis has quit [Read error: Connection reset by peer]
jpn has quit [Ping timeout: 252 seconds]
jpn has joined #ruby
walez___ has quit [Ping timeout: 264 seconds]
hellstabber has joined #ruby
sam113101 has quit [Ping timeout: 252 seconds]
grokify has quit [Remote host closed the connection]
perrierjouet has quit [Quit: WeeChat 3.7]
perrierjouet has joined #ruby
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
Guimauve|AFK has quit [Ping timeout: 264 seconds]
grokify has joined #ruby
some14u has joined #ruby
Guimauve|AFK has joined #ruby
markong has joined #ruby
Guimauve|AFK is now known as Guimauve
c10l has quit [Ping timeout: 268 seconds]
c10l has joined #ruby
jpn has quit [Ping timeout: 246 seconds]
nirvdrum has joined #ruby
TomyWork has joined #ruby
mikecmpbll has joined #ruby
c10l0 has joined #ruby
c10l has quit [Ping timeout: 264 seconds]
c10l0 is now known as c10l
Al2O3 has quit [Ping timeout: 260 seconds]
dviola has quit [Ping timeout: 248 seconds]
Guimauve has quit [Quit: The Lounge - https://thelounge.chat]
D_A_N has joined #ruby
hasley is now known as mahler
dviola has joined #ruby
nirvdrum has quit [Quit: nirvdrum]
jpn has joined #ruby
some14u has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jpn has quit [Ping timeout: 246 seconds]
c10l2 has joined #ruby
c10l has quit [Ping timeout: 246 seconds]
c10l has joined #ruby
jpn has joined #ruby
c10l2 has quit [Ping timeout: 252 seconds]
jpn has quit [Ping timeout: 264 seconds]
jpn has joined #ruby
grokify has quit [Remote host closed the connection]
jpn has quit [Ping timeout: 252 seconds]
grokify has joined #ruby
jpn has joined #ruby
grokify has quit [Ping timeout: 246 seconds]
<staff420> adam12: Ooh, very nice!
<staff420> Cheers mate :thumbsup:
jpn has quit [Ping timeout: 248 seconds]
szkl has quit [Quit: Connection closed for inactivity]
jpn has joined #ruby
John_Ivan has joined #ruby
phenom has quit [Ping timeout: 252 seconds]
reset has joined #ruby
D_A_N has quit [Ping timeout: 268 seconds]
D_A_N has joined #ruby
phenom has joined #ruby
yxhuvud has quit [Remote host closed the connection]
yxhuvud has joined #ruby
Guest2735 has quit [Quit: WeeChat 3.7]
D_A_N has quit [Ping timeout: 246 seconds]
D_A_N has joined #ruby
gr33n7007h has joined #ruby
eddof13 has joined #ruby
dionysus69 has quit [Ping timeout: 260 seconds]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
royo25 has quit [Quit: Bye]
eddof13 has joined #ruby
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
Vonter has quit [Ping timeout: 268 seconds]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 248 seconds]
desnudopenguino1 is now known as desnudopenguino
dionysus69 has joined #ruby
c10l has quit [Quit: See ya! o/]
justache is now known as justHaunted
c10l has joined #ruby
Vonter has joined #ruby
eddof13 has joined #ruby
c10l has quit [Quit: See ya! o/]
TomyWork has quit [Remote host closed the connection]
c10l has joined #ruby
c10l has quit [Client Quit]
John_Ivan is now known as John_CabbageFiel
John_CabbageFiel is now known as JohnCabbageField
mikecmpbll has quit [Ping timeout: 246 seconds]
walez___ has joined #ruby
Aminda has quit [Ping timeout: 258 seconds]
Aminda has joined #ruby
dnadev2 has joined #ruby
walez___ has quit [Ping timeout: 246 seconds]
legit has quit [Quit: WeeChat 2.8]
legit has joined #ruby
<dnadev2> probably an off topic question… i'm curious about the best way to go about interacting with the stripe api. my back end is a rails api and the front end is in vuejs. if the front end was in rails it’d be trival, but i'm wondering how to deal with the frontend being separate. i want vuejs to handle the stripe ui for checkout, but need the rails api save the orders data etc.
CrazyEddy has joined #ruby
mikecmpbll has joined #ruby
Guest44 has joined #ruby
<adam12> dnadev2: Vue will gain a token from Stripe, and you'll need to send that token to the Rails app, which will then attach it to a customer.
<adam12> (or use it some other way)
<dnadev2> ahh, so checkout via vuejs, that will result in a token, send token to api, have api talk with stripe and do what i have to
<adam12> dnadev2: Yeah. Presumably you'll have a Rails /orders endpoint or something. You could send the token along with that, or if you create a customer earilier in the flow, have a /customers/attach-token endpoint. There's many different approaches.
<adam12> I don't think Vue changes much, since you hae no choice but use Stripe Elements lately. I usually add it to a hidden form input, but there's no reason why it couldn't be a prop that's submitted as well.
* dnadev2 wonders if elements supports subscription payments
<adam12> Maybe just use Stripe Checkout? I'm sure it does.
<adam12> Tho that said, unless you have a very bogstandard business, beware the infamouse Stripe death.
<dnadev2> stripe death?
<adam12> dnadev2: Stripe approves everyone, then does the underwriting later once you hit a threshold. Sometimes the account closure is automated, and getting recourse to re-open it is challenging.
<adam12> dnadev2: If you search HackerNews, you can see history of it
<dnadev2> ahhhh, gotcha
<dnadev2> thanks for the help adam12!
<adam12> Lately I'm trying to use less Stripe features, and keep it bog-standard Charges. That way I can swap out Square or another gateway without much fan-faire.
<dnadev2> i have some direction now :)
<adam12> dnadev2: np!
<adam12> But if you want to get to market fast, I'd just ship on Stripe Checkout and have a backup plan.
<dnadev2> stripe checkout is basically just using a stripe landing page for checkout?
<adam12> dnadev2: Yeah.
<dnadev2> with that, do you still get a token that my vuejs could send back to my api?
<adam12> dnadev2: No. Vue is out of the loop for this. Stripe will send back a webhook to your app.
<adam12> dnadev2: They hit Checkout -> you redirect them to Stripe -> they fill in details and are then returned to your app -> Stripe sends webhook to fulfill order.
polishdub has quit [Quit: leaving]
<dnadev2> ok. i guess that could work too - vuejs provides the checkout button and get returned to the vue app, while the webhook hits my api. then in vuejs i can just talk to my api which will have done what it needs too after the webhook ping. sound reasonable?
polishdub has joined #ruby
<adam12> dnadev2: Yeah.
<dnadev2> \o/
jpn has quit [Ping timeout: 252 seconds]
legit has quit [Quit: WeeChat 2.8]
legit has joined #ruby
legit has quit [Client Quit]
legit has joined #ruby
Guest44 has quit [Quit: Client closed]
jpn has joined #ruby
Guimauve has joined #ruby
markong has quit [Ping timeout: 264 seconds]
jpn has quit [Ping timeout: 268 seconds]
dionysus69 has quit [Ping timeout: 264 seconds]
jpn has joined #ruby
<D_A_N> Does anyone know what _spec files are for? I'm working on this project that was written by several other people and am new to Ruby
<D_A_N> It's in /spec/services/
<D_A_N> A bunch of them, all postfixed with _spec
<D_A_N> I tried googling it but nothing really comes up
<D_A_N> I would think it's something to do with how this project uses phantomjs for testing
<adam12> D_A_N: They are generally test files. Some people would say they are part of the BDD style of testing (via specifications)
<adam12> D_A_N: They could be for RSpec (a BDD test framework) or they could be part of Minitest. Or they could be part of something else.
<adam12> Obviously the filename doesn't mean anything, and the contents could not match the filename, but that's the gist of it.
jpn has quit [Ping timeout: 246 seconds]
c10l has joined #ruby
c10l has quit [Client Quit]
c10l has joined #ruby
c10l has quit [Quit: See ya! o/]
Sheilong has joined #ruby
supay has joined #ruby
some14u has joined #ruby
c10l has joined #ruby
_ht has joined #ruby
r3m has quit [Quit: WeeChat 3.8-dev]
r3m has joined #ruby
jpn has joined #ruby
some14u has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
some14u has joined #ruby
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 260 seconds]
desnudopenguino1 is now known as desnudopenguino
<D_A_N> oh okay, I see in the read me it mentions using rspec
dionysus69 has joined #ruby
mikecmpbll has quit [Ping timeout: 264 seconds]
jpn has quit [Ping timeout: 260 seconds]
some14u has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
some14u has joined #ruby
grokify has joined #ruby
grokify has quit [Ping timeout: 255 seconds]
RougeR has joined #ruby
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
some14u has quit [Ping timeout: 252 seconds]
some14u has joined #ruby
<adam12> I can't believe I never thought about passing self.class to logger as progname before. Helps eliminate questions on where the log entry was from. logger.debug(self.class.to_s) { "Running" }
jpn has joined #ruby
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
<D_A_N> adam12: lemme ask you something else
<adam12> D_A_N: Shoot.
grokify has joined #ruby
jpn has quit [Ping timeout: 272 seconds]
dionysus69 has quit [Ping timeout: 260 seconds]
<D_A_N> this .slim template inherits from another template that has several "content_for" calls
<D_A_N> and I see there's an override_helper.rb /app/helpers/ folder that defines these "content_for" methods
grokify has quit [Ping timeout: 272 seconds]
<D_A_N> they look like def og_image(og_image)
<D_A_N> content_for(:og_image) { og_image }
<D_A_N> end
<D_A_N> and then in the parent template where it calls these methods, it looks like this
<D_A_N> - if content_for?(:og_image)
<D_A_N> meta property="og:image" content=image_url(content_for(:og_image))
some14u has quit [Ping timeout: 268 seconds]
<D_A_N> so I was attempting to define an array/object (not sure the correct wording for ruby) in the child template since it differs between pages
<D_A_N> so I was trying to pass a 2d array to the parent template through that method
<D_A_N> but then i came to find out it the only things i can pass to it are strings
some14u has joined #ruby
<D_A_N> so i looked up how to pass it a string of JSON and then parse that so I can add a for loop in the parent template that adds the meta
<D_A_N> but that didn't work out, what i ended up doing was creating a separate partial and putting the meta for the page in there, then passing the path to that partial to the parent template to render
<D_A_N> like this
<D_A_N> - if content_for?(:custom_meta)
<D_A_N> = render content_for(:custom_meta)
<D_A_N> (in the parent template)
<D_A_N> and in the child template - custom_meta '/partials/the_custom_meta'
<D_A_N> so it's very hacky, very big question in but the jist is that i was trying to pass a 2d array from the child template to the parent where i would loop through it and render a meta tag for each iteration
<D_A_N> so question is: why can i only pass strings to this "content_for" method
<adam12> At least for ERB (I don't know about slim but I'm guessing it is similar), content_for changes the variable that the markup is rendered into. That variable is a string. So swapping to a new string makes sense.
<adam12> It's a little muddy when you just pass a plain value to it, but consider that it can be use in a capture mode with a block and it makes sense.
hellstabber has quit [Quit: Connection closed for inactivity]
micah has joined #ruby
<adam12> IMHO, I'd just use the approach you did.
<D_A_N> passing a string that is JSON and then parsing it in the parent template?
<D_A_N> or you mean the path to the partial
<D_A_N> hmm
<adam12> If you can imagine the view as one big string, called @slimout, then when you reach a content_for, it renames @slimout to @slimout-old, makes a new @slimout as a string, then calls the block and assigns the return value to the string. Then puts the @slimout-old back to @slimout and continues.
<micah> if @issue.confidential? returns true/false, can I pass that in a function, like: mail_new_thread(@issue, issue_thread_options(@issue.author_id, reason, @issue.confidential)) -- or do i need to put a ? at the end there?
<adam12> The partial with the custom_meta.
<adam12> I'd just content_for without the partial.
<adam12> and then content_for :custom_meta in your layout file (where the `<head>` element would live)
<adam12> micah: It needs to have a `?` there.
<D_A_N> so instead of - custom_meta 'personal_loans/partials/sofe_meta' in the child template just replace the path there with the actual meta tags
<adam12> micah: Well, it doesn't. Does `@issue.confidential` exist? It would use that if so (which may or may not be a boolean)
<adam12> D_A_N: Yeah. I'm presuming there's almost no value in the partial.
<D_A_N> hmm
<adam12> micah: The contract of ? methods is generally that it returns true/false. There's nothing saying that @issue.confidential would be true/false, but it _might_ be truthy/falsy.
<micah> adam12: @issue.confidential does exist, yes
<micah> and I want to pass the boolean value of that into issue_thread_options()
<adam12> micah: So use the ? method if you _want_ a boolean. It reveals the intent that it should be true/false and not something that might be truthy or falsey.
<micah> adam12: ah ok, great thanks!
<adam12> If you're using Rails, I think ActiveSupport automatically adds predicate methods (? methds) for all boolean columns.
<adam12> But obviously in a Plain Old Ruby Object, there is only a ? method if you add it :)
hellstabber has joined #ruby
hightower2 has joined #ruby
ur5us has joined #ruby
<micah> adam12: yeah, this is rails - what happens if it is not set?
<adam12> micah: Good question. I'm actually not sure.
<adam12> micah: In theory it would be nil, because the state is ambiguous.
Guimauve has quit [Ping timeout: 246 seconds]
<adam12> micah: But for booleans, I'd probably recommend not having a nil for those columns, and just pick a default / set not null.
<micah> ok, i just dont want it to thrown an error or something
<micah> adam12: yeah, I did this: def issue_thread_options(sender_id, reason, confidentiality: false)
<micah> to set the value to a default
<adam12> micah: That wont' work, because you can still pass nil as a value.
<micah> ooh true
<adam12> I'd set the default to nil, then handle it inside the method body.
<adam12> confidentiality = false if confidentiality.nil?
<adam12> (you can't use ||= here because it will bite ya)
<micah> adam12: by using double negation?
<adam12> micah: Nah, you can double negate here too, if you really wanted to.
<adam12> micah: I meant the or-equals shorthand.
<adam12> foo ||= "bar"
<adam12> But it doesn't work for booleans.
<micah> ah ok, i was thinking confidentiality = !!confidentiality
<micah> but I think confidentiality = false if confidentiality.nil? is more clear
<adam12> You could do that too, if you wanted.
<adam12> Yes, I think it reveals it's intent better.
Sankalp- has joined #ruby
Sankalp has quit [Ping timeout: 268 seconds]
Sankalp- is now known as Sankalp
jpn has joined #ruby
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
grokify has joined #ruby
grokify has quit [Remote host closed the connection]
grokify has joined #ruby
_ht has quit [Quit: _ht]
otisolsen70 has quit [Quit: Leaving]
grokify has quit [Remote host closed the connection]
wand has quit [Ping timeout: 258 seconds]
markong has joined #ruby
wand has joined #ruby
JohnCabbageField is now known as John_Shuul
John_Shuul is now known as John_Schuuman
grokify has joined #ruby
teclator has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
grokify has quit [Ping timeout: 260 seconds]
polishdub has quit [Remote host closed the connection]
polishdub has joined #ruby
grokify has joined #ruby
jpn has quit [Ping timeout: 268 seconds]
szkl has joined #ruby
John_Schuuman has quit [Read error: Connection reset by peer]
John_Schuuman has joined #ruby
weaksauc_ has joined #ruby
Guimauve has joined #ruby
weaksauce has quit [Ping timeout: 248 seconds]
jpn has joined #ruby
jpn has quit [Ping timeout: 246 seconds]
<staff420> Anybody know why this has zero effect? https://thoughtbot.com/blog/content-compression-with-rack-deflater
<staff420> Using Rails 7.0.4 with Puma 5.6.5. `use Rack::Deflater` shows up when typing `rake middleware`. Tried adding it to `production.rb` as well to no avail.
<havenwood> staff420: Sanity check `module YourApp` is swapped out for `module YourRealAppName`.
<staff420> havenwood: Yup, all good
<havenwood> staff420: Do you check with a request asking for gzip?
<staff420> Nope, haven't tried that yet
<staff420> Will do
<staff420> I was just reloading my page and hoping to see my page source being compressed into a single line
jpn has joined #ruby
<havenwood> staff420: Rack::Deflater adds support for compression over the wire. It's a great thing to use, but it looks like compressed data over the wire then is decompressed by the other end.
<havenwood> staff420: It doesn't do anything unless you request gzip or deflate, or you can add brotli.
<havenwood> They're great, and make payloads much smaller, but it's a different thing than source minification, just to be clear.
<havenwood> If you request `gzip` in your HTTP request, it should work.
<havenwood> Some Ruby HTTP clients also support manual deflation.
jpn has quit [Ping timeout: 260 seconds]
<staff420> Nice, never heard of brotli before!
<staff420> Was just trying `curl -i --head "Accept-Encoding: gzip,deflate" http://localhost:5000` from https://stackoverflow.com/questions/7236583/where-to-insert-rackdeflater-in-the-rack as well as adding `use Rack::Deflater` straight into `config.ru` but still nothing.
<staff420> Ah yes, thanks for making that distinction. I thought it was one and the same :)
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood> staff420: Try?: curl -H "Accept-Encoding: gzip" -I http://localhost:5000
<havenwood> You can add `--compressed` but I guess the point is to see it's indeed compressed not decompress it. :)
<staff420> Success!: Content-Encoding: gzip
<havenwood> 👍
<staff420> :D
<staff420> Any clues about minifying HTML though?
<staff420> I don't want people reading all my comments and stuff
<staff420> I remember some years back someone here wrote a middleware to basically just .join("\n\n") all the output
<staff420> Anyway probably not important, thanks for the help!
Rounin has quit [Ping timeout: 252 seconds]
cartdrige has joined #ruby
<havenwood> staff420: Most tools for minifying JavaScript and HTML are in the JavaScript ecosystem, but there are Ruby options too.
<havenwood> staff420: Rails used to use Sprockets for the "asset pipeline" but uses Webpacker these days.
<havenwood> staff420: If it's just HTML you care about, there's a tidy gem (I dunno if it's maintained) or some pure Ruby options, or you can use Nogogiri yourself. I'd usually think of Webpack for HTML and JavaScript minification. Hem.
<havenwood> staff420: I'd think of it as normal to do gzip compression on the fly, and that's fine to do via middleware. HTML and JavaScript minification are usually done ahead of time and uploaded minified.
<havenwood> You could do a middleware for HTML minification, but I don't know of a maintained one since most folk opt to do it ahead of time.
<havenwood> A gzip or brotli compression and decompression are super efficient and low CPU usage.
<havenwood> I think the thinking is HTML and JavaScript minifying take more heavy lifting, so do it up front.
jpn has joined #ruby
jpn has quit [Ping timeout: 260 seconds]
Sheilong has quit [Quit: Connection closed for inactivity]
jpn has joined #ruby
Guimauve has quit [Quit: The Lounge - https://thelounge.chat]
gonix has joined #ruby
jpn has quit [Ping timeout: 246 seconds]
jpn has joined #ruby
<staff420> Hey! Just got back
<staff420> The Tidy gem, will check it out
<staff420> This is all new to me, never been in a situation where my site is about to go live for the first time :)
<staff420> Sprockets though, I just had a battle with it. Just recently Rails started using Propshaft for asset management instead. But whenever I include a gem that has Sprockets as a dependency, Sprockets will take over the entire ecosystem and mess things up :/
jpn has quit [Ping timeout: 252 seconds]
<staff420> Solidus is a mess :/ someone needs to clean it up
<staff420> This brotli looks awesome thanks again for the intro
<staff420> (ref. https://github.com/rails/propshaft/issues/114 - Blocking Sprockets seeping in from gem dependencies #114)