<KrzaQ>
is there a printf format that would let me say "zero-filled to two characters to the left, at most 2 decimal digits after the dot"? Conceptually something like `%02.2f`, which does not work for me
<KrzaQ>
oh, %05.2f actually works, because it's the number of characters
<KrzaQ>
thanks folks
Bounga has quit [Ping timeout: 272 seconds]
jenrzzz has joined #ruby
drincruz has quit [Ping timeout: 258 seconds]
sylario has quit [Quit: Connection closed for inactivity]
akem has quit [Ping timeout: 260 seconds]
Swyper has quit [Remote host closed the connection]
xco has joined #ruby
<xco>
hi all.
<xco>
is Ruby still on track to making all strings frozen by default in Ruby 3 or something changed along the way?
<lmat>
I have a <%= submit_tag 'Add New', class: 'btn btn-primary btn-block', id: 'add-document-btn' %> in a index.html.erb. What code is run when that submit is clicked?
BSaboia has joined #ruby
iNs has joined #ruby
gavlee has quit [Excess Flood]
gavlee has joined #ruby
<adam12>
lmat: Depends on where the form action is pointed to.
dfucci has quit [Ping timeout: 258 seconds]
BSaboia has quit [Quit: This computer has gone to sleep]
<lmat>
adam12: How do I tell that? At the bottom of that index.html.erb file, there is <%= render partial: 'form' %> . Surely that form doesn't matter because it's *below* the submit tag? So I suppose this index.html.erb is being rendered *within* some form...
dfucci has joined #ruby
<adam12>
lmat: View the page source in your browser.
<lmat>
Okay, verified there is no form surrounding the <input> :-/
<lmat>
adam12: Yeah, just did :-)
<adam12>
lmat: Ah interesting.
* lmat
sigh
<adam12>
lmat: Does it work? I didn't think input's could be floating (tho button's can)
BSaboia has joined #ruby
<adam12>
lmat: It's possible this is a Javascript only button.
<lmat>
adam12: Yes, it works. I guess the browser is being generous and interpreting the input in the context of the form even though the form is later.
<adam12>
lmat: If you're familiar with Chrome DevTools, use Inspector to determine if anything is listening to Click.
<adam12>
lmat: Or maybe grep for add-document-btn. The fact that it's an `id` makes me think it might have a listener attached to it.
howdoi has quit [Quit: Connection closed for inactivity]
<lmat>
Okay.
<lmat>
adam12: Good call! I found some .coffee js.
<adam12>
lmat: fun :)
<adam12>
Now just need some styles attached to the id, and an old version of Coffeescript which doesn't support sourcemaps, and we're living in 2010 again!
<lmat>
\o/
<lmat>
adam12: This <input> does something to another <input> (a file picker) that *is* inside the form.
<adam12>
lmat: It's <input>'s all the way down. Yay webdev.
<lmat>
How do I tell what code runs when the file picker inside this form: <%= form_for [@report, @document], remote: true do |f| %> is used?
<adam12>
lmat: You'll need to find the Rails controller / action that it points to. See if anything sticks out in `rails routes` first.
<adam12>
lmat: That's a polymorphic path (iirc?) and it doesn't have a name, so Rails is making up a name for it somehow. If you can see the actual path generated in the <form> element, could use that to narrow it down.
<adam12>
It's probably reports_document_path or something.
<lmat>
/reports/5728/documents
<lmat>
Okay, I'll check the routing table.
<adam12>
lmat: Routing table will say something like reports#documents or something.
<lmat>
Yes, I think I see the entry: "resources :documents, only: [:index, :create, :update, :destroy]" inside resources :reports. A new document is being created. I added a def create in my document.rb model with a puts "howdy", but that logging statement never hit the logs.
<lmat>
(I then tried def new but that didn't work either).
<lmat>
I'm trying to set a value on the new document before it's getting saved :-)
<adam12>
lmat: My guess is you won't be able to use `def create`. If it's SomeModel.create you're thinking of, that's a class method and you're overwriting an instance method. `def self.create(*args)` might have got you closer but bad idea with ActiveRecord. Stick to callbacks or modify the code that calls `create` inside your controller.
<lmat>
adam12: "modify the code that calls `create' inside your controller." This sounds like a great idea, but I don't know where that happens :-/
<lmat>
It would be in the report controller (not the document controller), right?
<adam12>
lmat: DocumentsController#index (the index method in the DocumentsController) is my guess. Paste that block of your routes.rb somewhere so I can look but you said nested so that sounds right.
<adam12>
lmat: if you look at the log of your `rails server` comand, it's likely in there as well.
<rubydoc>
stderr: -e:4:in `<main>': undefined method `utf' for 2020-02-28 00:00:00 +0000:Time (NoMethodError)... check link for more (https://carc.in/#/r/9cx8)
<Industrial>
bradfordli123: test it if it makes you feel more secure that it will keep working that way in the future.
Uncle_Cid has joined #ruby
<bradfordli123>
Industrial sounds like "its up to me" hahah
<bradfordli123>
thanks =]
<Industrial>
np.
<Industrial>
Has anyone worked with Falcon? When I run my code with `rackup -o localhost -p 8080` then it runs fine. When I run it with `falcon serve --bind http://localhost:8080 --count 1 -c config.ru` then I get errors about all gems that I'm requiring (well, the first one and then it dies :p)
UncleCid has quit [Ping timeout: 256 seconds]
djdduty has quit [Quit: ZNC 1.6.6+deb1ubuntu0.2 - http://znc.in]
djdduty has joined #ruby
djdduty has quit [Changing host]
djdduty has joined #ruby
xco has joined #ruby
Industrial has quit [Ping timeout: 260 seconds]
Industrial has joined #ruby
zacts has quit [Ping timeout: 272 seconds]
zacts has joined #ruby
apteryx is now known as Guest83291
Guest83291 has quit [Killed (weber.freenode.net (Nickname regained by services))]
BTRE has quit [Ping timeout: 260 seconds]
apteryx has joined #ruby
BTRE has joined #ruby
djdduty has quit [Quit: ZNC 1.6.6+deb1ubuntu0.2 - http://znc.in]
djdduty has joined #ruby
infernix has joined #ruby
zacts has quit [Quit: WeeChat 2.8]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
cliluw has quit [Ping timeout: 246 seconds]
sarna has joined #ruby
x0n has quit [Ping timeout: 246 seconds]
x0n has joined #ruby
RiPuk has quit [Ping timeout: 240 seconds]
RiPuk has joined #ruby
Industrial has quit [Ping timeout: 260 seconds]
Industrial has joined #ruby
jenrzzz has quit [Ping timeout: 272 seconds]
RiPuk_ has joined #ruby
RiPuk has quit [Ping timeout: 264 seconds]
cliluw has joined #ruby
RiPuk_ has quit [Ping timeout: 240 seconds]
RiPuk has joined #ruby
jenrzzz has joined #ruby
ur5us has joined #ruby
jetchisel has joined #ruby
ur5us_ has joined #ruby
segy has quit [Excess Flood]
segy has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
ur5us_ has quit [Ping timeout: 265 seconds]
oddp has joined #ruby
mnathani has quit []
imode has quit [Ping timeout: 256 seconds]
mossplix has joined #ruby
bradfordli123 has quit [Remote host closed the connection]
G has quit [Quit: Foo]
G_ has joined #ruby
G_ is now known as G
jenrzzz_ has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
jenrzzz_ has quit [Ping timeout: 246 seconds]
mossplix has quit [Ping timeout: 240 seconds]
akem has joined #ruby
dfucci has quit [Ping timeout: 256 seconds]
tau has joined #ruby
tau has quit [Changing host]
tau has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
charrit69 has joined #ruby
_whitelogger has joined #ruby
Garb0_ has joined #ruby
Garb0 has quit [Ping timeout: 265 seconds]
chris__ has joined #ruby
chris__ has quit [Ping timeout: 240 seconds]
guardianx has joined #ruby
TomyWork has joined #ruby
tau has quit [Quit: HAUHE]
mossplix has joined #ruby
s_ has quit [Ping timeout: 260 seconds]
s_ has joined #ruby
lightstalker has joined #ruby
mossplix has quit [Remote host closed the connection]
guardianx has quit [Read error: Connection reset by peer]
<MadLamb>
I'm maintaining an old project that uses paperclip. I want to obtain the attachment url in the model. In the view it seems you can call a inexistent .url property when passing the attachment to the image_tag, but if I call that property directly on the model i get a "NoMethodError: undefined method `url..."
Jonopoly has joined #ruby
<jhass>
compare the .class'es of where you can call url and where not
guardianx has joined #ruby
mossplix has joined #ruby
drincruz has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
guardianx has quit [Read error: Connection reset by peer]
guardianx has joined #ruby
braincrash has quit [Ping timeout: 260 seconds]
ErhardtMundt_ has joined #ruby
teclator_ has joined #ruby
ErhardtMundt has quit [Quit: No Ping reply in 180 seconds.]
rippa has quit [Ping timeout: 260 seconds]
olspookishmagus has quit [Ping timeout: 260 seconds]
olspookishmagus has joined #ruby
teclator has quit [Ping timeout: 260 seconds]
braincrash has joined #ruby
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
<jhass>
where you call .url, call .class and output it in some way
burningserenity has joined #ruby
<jhass>
log, p, binding.pry, whatever
akem has quit [Quit: Leaving]
endorama has joined #ruby
guardianx has joined #ruby
drincruz has quit [Ping timeout: 264 seconds]
guardianx has quit [Excess Flood]
guardianxx has joined #ruby
Scient has quit [Ping timeout: 260 seconds]
guardianxx has quit [Excess Flood]
Scient has joined #ruby
<MadLamb>
jhass, I see
Arkantos has quit [Ping timeout: 260 seconds]
Arkantos_ has joined #ruby
olspookishmagus is now known as Guest90309
bmurt has joined #ruby
drincruz has joined #ruby
teclator_ is now known as teclator
<MadLamb>
jhass, I did pp on .class, and it shows the Attachment model and it doesnt have any url method or property, but this is something I already knew. The question is that when you use it on the view with image_tag it behaves as there would be a method/property...
<MadLamb>
and how to get the same behavior in the model
<jhass>
so what's the class of whatever you pass to image_tag?
fanta1 has joined #ruby
oziyasin has joined #ruby
burningserenity has quit [Ping timeout: 246 seconds]
<MadLamb>
jhass, the class is the ActiveRecord model
<jhass>
what makes you say calling url works on it in the view then?
<MadLamb>
jhass, I also checked this class, there is no method or propety url
<jhass>
maybe that premise is wrong
<MadLamb>
jhass, yeah that is what i want to know too
<MadLamb>
jhass, some magic
<jhass>
so what makes you assume it works by calling url?
<MadLamb>
jhass, the class Project has this Attachment (which then is paperclip)
<MadLamb>
jhass, because I see in the view it calls a method, I open the method and it calls project.attachment.url
<MadLamb>
jhass, that is the parameter provided to image_tag
<jhass>
that's all it does, no branching or so?
<MadLamb>
jhass, inheritance?
<jhass>
branching is if/else
<jhass>
ternary
<jhass>
case/when
<MadLamb>
ah yes it does have it but in all the branches it calls .url
<jhass>
but maybe not on the same thing?
<jhass>
it's hard to debug this through IRC :P
troulouliou_dev has quit [Read error: Connection reset by peer]
troulouliou_dev has joined #ruby
Jonopoly has quit [Quit: WeeChat 2.8]
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Secret-Fire has quit [Read error: Connection reset by peer]
nate48423 has quit [Ping timeout: 246 seconds]
Secret-Fire has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.8]
nate48423 has joined #ruby
ur5us_ has joined #ruby
nate48423 has quit [Ping timeout: 256 seconds]
nate48423 has joined #ruby
gitter1234 has joined #ruby
Secret-Fire has quit [Remote host closed the connection]
Secret-Fire has joined #ruby
schne1der has quit [Ping timeout: 240 seconds]
gitter1234 has quit []
BSaboia has joined #ruby
TCZ has joined #ruby
leah2 has quit [Ping timeout: 265 seconds]
BSaboia has quit [Quit: This computer has gone to sleep]
leah2 has joined #ruby
BSaboia has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
stdedos has joined #ruby
BSaboia has joined #ruby
BSaboia has quit [Client Quit]
nate48423 has quit [Ping timeout: 246 seconds]
nate48423 has joined #ruby
impermanence has joined #ruby
Axy has quit [Read error: Connection reset by peer]
BSaboia has joined #ruby
s_ has quit [Ping timeout: 260 seconds]
s_ has joined #ruby
BSaboia has quit [Ping timeout: 246 seconds]
chris__ has joined #ruby
mossplix has quit [Remote host closed the connection]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
BSaboia has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
<lmat>
Is it common to feel like rails is sort of like black magic? I feel like nothing is discoverable in any of these frameworks. In order to know what's going on, you have already to know what's going on.
chris__ has quit [Ping timeout: 256 seconds]
wymillerlinux has joined #ruby
stdedos has quit [Quit: Connection closed]
TCZ has quit [Quit: Leaving]
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
<apotheon>
lmat: It is a bit like black magic.
<apotheon>
lmat: My usual phrasing is "Rails is too full of magic, and Django is too full of thumbscrews."
<lmat>
apotheon: It seems utterly undiscoverable. Is that a common reaction?
<apotheon>
(because people seem to think "thumbscrew" is a fastening device on computers)
<apotheon>
It happens sometimes.
<apotheon>
That reaction, I mean.
<apotheon>
It's not *abnormal*.
<lmat>
apotheon: For instance, in C++, you look at the include files and read them until you see the definition of all functions and structs in scope. Definitions of functions are all *explicitly* given at linking stage. In Java, all classes are specified explicitly (with import statements, too) and *explicitly* specified in the compiler step. With rails, I add a line in some /config/* then "magically" I have extra
<lmat>
functions available to me in all my controllers without "including" those new functions in any way.
<lmat>
Maybe the best way to put it is: the "includes" (#include in C and C++, import in Java, using in C#, etc.) in rails are scattered all over the project and apply to some non-obvious set of classes and code files.
<lmat>
So, to find the definition of any particular function is completely opaque.
nate48423 has quit [Ping timeout: 258 seconds]
<apotheon>
There's kind of a hierarchy of files that include each other, and your source files (e.g. a model file) is included along with other stuff. That's why it works that way. The same could be done in pretty much any programming language that allows one file to include another.
<apotheon>
If you want stuff that's part of Rails, read Rails documentation, which often includes links to source code.
<lmat>
apotheon: Except in other languages, it's very obvious which files are being bundled together.
<apotheon>
Look at a model and tell me how that, being bundled together with others by a different file, is supposed to make it obvious that something else is including it.
<lmat>
apotheon: I think that's the confusing bit: in rails something *else* is including my model. In the other languages, *my* code is including everything it needs.
<apotheon>
That's like saying that when you edit a header file you should then be able to tell what some other file is including along with the header file you just edited.
<apotheon>
The reason Rails does it -- the reason for the magic -- is so that you don't need every single model, view, and controller file to have the same giant pile of inclusions in it.
<apotheon>
It's a different way of doing things, and it just takes time and familiarity to get use to it.
<lmat>
apotheon: Yup. And the "black magic" (opaque functionality) is the price we pay.
<apotheon>
It has its downsides, of course. Every architectural choice in every framework in every language is full of trade-offs.
nate48423 has joined #ruby
<apotheon>
I love both C and Ruby. I wouldn't say I love Rails, but it's very convenient sometimes.
<apotheon>
I'm acutely aware of many trade-offs in part because I'm familiar with, and appreciate, both languages' ways of doing things.
ellcs has quit [Ping timeout: 260 seconds]
<apotheon>
It actually took a *long* time for me to properly appreciate C, despite the fact I literally learned my first C about fifteen years before I learned my first Ruby, because the real elegance of C is basically ignored or hidden by everyone and everything that sets out to "teach" C.
<lmat>
apotheon: "read Rails documentation" This is what I was talking about earlier, "In order to know what's going on, you have already to know what's going on." That is, when working on a new project, knowing where functions are defined or how they're made available is non-obvious. I think it's not good for maintenance. Piece of cake for new development, but I'm maintaining other code and it is FRUSTRATING.
<apotheon>
A key to appreciating each, though, is to accept that things are done differently, and there will be growing pains.
<lmat>
apotheon: I think I would have a good time writing a new application in rails.
<apotheon>
There's a lot of stuff to help you look up stuff. There are method search interfaces online, for instance.
<lmat>
Then I would be baking in my own black magic :-)
<apotheon>
I can understand the frustration.
<apotheon>
I just urge you to understand, in turn, that there are trade-offs, and it generally requires a bit of patience to learn to appreciate them.
<apotheon>
It'll make your life less stressful and difficult, I think.
leftylin1 is now known as leftylink
<apotheon>
lmat: What kind of method definition are you trying to find?
<apotheon>
Is it something written by another dev on the application project?
<lmat>
When I rearrange to require 'rspec/rails'; require 'devise'; require 'spec_helper'; then I get the error I already posted: https://imgur.com/zE9xjZV.png
<lmat>
I think I feel all the way across the wire how you feel reading through this stuff. You feel tired. You think "Oh man, I don't have time for this." I know you feel this way because I feel this way. TOO MUCH BLACK MAGIC.
<apotheon>
I've gotta go. I'm waiting on a call to get a vehicle from the mechanic, I have company coming over in about an hour, and I'm not done with stuff I need to finish before both of those things.
<apotheon>
Good luck.
<apotheon>
Sorry.
<lmat>
apotheon: No apology necessary. I hope your car is all fixed up and ready to go! And enjoy your company tonight! Later!
<al2o3-cr>
anyone have a good idea of how to stop freeing @work twice, my brain is fried lol
jenrzzz has joined #ruby
BSaboia has quit [Client Quit]
<al2o3-cr>
ping me if anyone has an idea wtf i've done wrong :P
nate48423 has quit [Ping timeout: 240 seconds]
nate48423 has joined #ruby
quazimodo has quit [Ping timeout: 240 seconds]
<leftylink>
al2o3-cr: may I ask dumb question. so comment says SEGV if digest called a second time - is that really because of being freed a second time? It looks like what's written there should work to make it not be freed twice. and instead that I would be concerned about @work being used in digest after it has been freed
<al2o3-cr>
leftylink: got an idea how to go about this?
stryek has quit [Quit: Connection closed for inactivity]
BSaboia has joined #ruby
<al2o3-cr>
i'll update the gist with the trace.
colins has quit [Quit: WeeChat 2.8]
<al2o3-cr>
jeez christ now it just segfaults on the first call to digest :(
nate48423 has quit [Ping timeout: 240 seconds]
nate48423 has joined #ruby
<al2o3-cr>
gist updated
<al2o3-cr>
wtf Segmentation fault at 0x0000000000000000 how???
<al2o3-cr>
a null pointer
<al2o3-cr>
i give up for today.
<al2o3-cr>
hold up, i see it... i think.
<al2o3-cr>
i'm initializing @work with the default value of @blocks in the initialize method, but then, if i change @blocks in the block e.g tuning.blocks = 350_000 it won't have enough memory for the calculation because it's already been allocated 100_000
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<al2o3-cr>
move @work into #digest
<al2o3-cr>
or set it after the yield ??
tau has joined #ruby
troulouliou_dev has quit [Quit: Leaving]
<al2o3-cr>
ffs i was passing blocks and iterations the wrong way round. blocks should be 350_000 and iterations should be 7 der. right that's that solved, back to the original question.
<al2o3-cr>
leftylink: i've updated the gist with a second trace to show that calling digest a second time seg faults.
<al2o3-cr>
it's exactly 16 bytes difference so it's definitely @work being freed a second time, i'm pretty sure.
<al2o3-cr>
leftylink: what did you mean when you said "and instead that I would be concerned about @work being used in digest after it has been freed"