havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.7.0, 2.6.5, 2.5.7: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ and select Ruby as the language | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
turbo_choo has quit [Ping timeout: 268 seconds]
TCZ has joined #ruby
pandakekok9 has joined #ruby
poontangmessiah has quit [Ping timeout: 268 seconds]
sameerynho has quit [Ping timeout: 260 seconds]
DaRock has joined #ruby
dumptruckman has quit [Ping timeout: 252 seconds]
dionysus69 has quit [Ping timeout: 272 seconds]
gylpm has quit [Ping timeout: 260 seconds]
ur5us has quit [Ping timeout: 260 seconds]
dumptruckman has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Esa_ has quit []
davidw has quit [Ping timeout: 240 seconds]
ur5us has joined #ruby
markopasha has joined #ruby
gylpm has joined #ruby
skryking_ has joined #ruby
skryking has quit [Ping timeout: 272 seconds]
evert has quit [Quit: ZNC - https://znc.in]
turbo_choo has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
anveo has joined #ruby
poontangmessiah has joined #ruby
hays has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
felipec has joined #ruby
evert has joined #ruby
davidw has joined #ruby
turbo_choo has quit [Ping timeout: 265 seconds]
<felipec> Anybody has any suggestion how to improve a directed acyclic traversal code? https://dpaste.org/ozTm
turbo_choo has joined #ruby
TCZ has quit [Quit: Bye Bye]
AJA4350 has quit [Quit: AJA4350]
hays has joined #ruby
ctOS has quit [Quit: Connection closed for inactivity]
gix has quit [Quit: Client exiting]
<havenwood> felipec: #each_dependency and #each_dep are the same method? recursive?
<felipec> havenwood: yeap, I forgot to rename the second one
<havenwood> felipec: my first thought for line 3, for better or worse, was: visited.fetch(dependecy) { next }
<havenwood> felipec: I usually don't mix `block` and `yield`. Is line 5 producing a side effect?
<havenwood> felipec: block.call(dependency)
<havenwood> felipec: but what's it doing?
<havenwood> felipec: this looks good to me. you could enable TCO if there are enough dependencies to possibly SystemStackError.
<felipec> havenwood: yield works fine. I changed the code to block.call; no change.
<havenwood> I've thought a few time that `with_tail_call_optimization: true` might be nice for #require and #require_relative.
<havenwood> Here's #require_relative with TCO: https://gist.github.com/havenwood/3c5a5e1476c811460992
<havenwood> felipec: Yeah, yield and block work fine together. I was just curious what was being yielded, since the value isn't being used.
<havenwood> felipec: I assume used for side effects?
poontangmessiah has quit [Ping timeout: 240 seconds]
wildtrees has quit [Quit: Leaving]
<havenwood> felipec: My `block.call` comment was solely about mixing `block` and `yield` usage. maybe just for old school performance reasons, but I prefer `yield` to `block.call`. If I sacrifice the performance to use `&block` then I `block.call` instead of `yield`. Not important, particularly.
<havenwood> I just all-yield as preference, but if I block, I all-block fully.
poontangmessiah has joined #ruby
<havenwood> Now that passing &block through is cheaper, there may be an argument for using yield with &block, in a particular circumstance. ¯\_(ツ)_/¯
<havenwood> There were some great optimizations in Ruby 2.5. See this PR for bechmarks: https://github.com/JuanitoFatas/fast-ruby/pull/141/files
sergioro has joined #ruby
skryking_ has quit [Quit: Konversation terminated!]
<havenwood> 3x faster is a good bit faster! https://bugs.ruby-lang.org/issues/14045
<havenwood> Yeah, my own benchmarks argue against me.
<havenwood> felipec: Never mind, haha! You have it optimally.
<havenwood> Since Ruby 2.5, you haven't paid the full penalty until you #call.
<havenwood> My suggestion is only relevant pre-2.5.
* havenwood makes a note to live in the now
<felipec> I wonder if it makes sense to make it an enumerator
poontangmessiah has quit [Quit: WeeChat 2.7]
gylpm has quit [Ping timeout: 240 seconds]
sgen has quit [Ping timeout: 240 seconds]
gylpm has joined #ruby
ttoocs has joined #ruby
<felipec> How about a shorthand for enum.each? def each_dep() deps().each { |e| yield e } end
Elundia has quit [Remote host closed the connection]
Elundia has joined #ruby
bruce_lee has quit [Ping timeout: 258 seconds]
bruce_lee has joined #ruby
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
<havenwood> felipec: You might consider also doing a: return enum_for(:each_dep) unless block_given?
chalkmon1 has joined #ruby
chalkmonster has quit [Ping timeout: 268 seconds]
davidw has quit [Ping timeout: 240 seconds]
<felipec> havenwood: Nicee
<felipec> Why unless block_given?
<havenwood> felipec: if the block is given, you'd: deps.each ...
<havenwood> felipec: It's a common pattern when making your own to: return enum_for(__method__) unless block_given?
<havenwood> felipec: then go on to do what happens if the block IS given.
<havenwood> felipec: If you don't care about handling a case where non block is given, no need.
<havenwood> &>> [1, 2, 3].each
<rubydoc> # => #<Enumerator: [1, 2, 3]:each> (https://carc.in/#/r/8f1r)
Elundia has quit [Remote host closed the connection]
<havenwood> felipec: ^ so you return an Enumerator if no block is given, rather than: LocalJumpError: no block given (yield)
<havenwood> &>> def each; return enum_for(__method__) unless block_given?; [1, 2, 42].each { |n| yield n } end; each.to_a # felipec
<rubydoc> # => [1, 2, 42] (https://carc.in/#/r/8f1s)
normanrockwell has joined #ruby
normanrockwell has quit [Client Quit]
<havenwood> &>> def each; [1, 2, 42].each { |n| yield n } end; each.to_a # felipec
<rubydoc> stderr: -e:4:in `block in each': no block given (yield) (LocalJumpError)... check link for more (https://carc.in/#/r/8f1t)
Exuma has joined #ruby
lineus_ has quit [Ping timeout: 240 seconds]
grilix has quit [Ping timeout: 246 seconds]
<felipec> havenwood: right, I got it, but I already wrote an enumerator, so... block_given? ? enum.each { |e| yield e } : enum
Exuma has quit [Client Quit]
<havenwood> felipec: ah, right - yes
lineus has joined #ruby
chalkmonster has joined #ruby
chalkmon1 has quit [Ping timeout: 265 seconds]
duderonomy has joined #ruby
grilix has joined #ruby
<felipec> havenwood: this seems a bit overkill: https://dpaste.org/EEzU
insolentworm has quit [Ping timeout: 250 seconds]
insolentworm has joined #ruby
LenPayne has quit [Ping timeout: 250 seconds]
LenPayne has joined #ruby
linuus has joined #ruby
Mon_Ouie has quit [Ping timeout: 250 seconds]
swistak35 has quit [Ping timeout: 250 seconds]
linuus_ has quit [Ping timeout: 248 seconds]
balo has quit [Ping timeout: 250 seconds]
balo has joined #ruby
unixabg has quit [Ping timeout: 250 seconds]
swistak35 has joined #ruby
unixabg has joined #ruby
fphilipe_ has joined #ruby
Mon_Ouie has joined #ruby
fphilipe_ has quit [Ping timeout: 265 seconds]
Elundia has joined #ruby
houhoulis has quit [Remote host closed the connection]
Elundia is now known as Guest83134
Guest83134 has left #ruby [#ruby]
orbyt_ has joined #ruby
<felipec> Ahhh, this is better: https://dpaste.org/KOZ3
markopasha has quit [Remote host closed the connection]
chalkmonster has quit [Ping timeout: 258 seconds]
pwnd_nsfw has quit [Ping timeout: 268 seconds]
turbo_choo has quit [Ping timeout: 265 seconds]
turbo_choo has joined #ruby
zdm has joined #ruby
anveo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kapil_ has joined #ruby
akemhp_ has joined #ruby
akemhp has quit [Ping timeout: 272 seconds]
cliluw has quit [Read error: Connection reset by peer]
segy has quit [Excess Flood]
cliluw has joined #ruby
segy has joined #ruby
pwnd_nsfw has joined #ruby
houhoulis has joined #ruby
pwnd_nsfw has quit [Ping timeout: 260 seconds]
brool has joined #ruby
felipec has quit [Ping timeout: 240 seconds]
factormystic has quit [Read error: Connection reset by peer]
jaequery has quit [Read error: Connection reset by peer]
jaequery has joined #ruby
tsrt^ has joined #ruby
jaequery has quit [Remote host closed the connection]
jaequery has joined #ruby
jaequery has quit [Remote host closed the connection]
Exuma has joined #ruby
chalkmonster has joined #ruby
pwnd_nsfw has joined #ruby
Exuma has quit [Quit: Textual IRC Client: www.textualapp.com]
pwnd_nsfw has quit [Ping timeout: 240 seconds]
Elundia has joined #ruby
Elundia has quit [Excess Flood]
Elundia has joined #ruby
Elundia has quit [Excess Flood]
fphilipe_ has joined #ruby
brool has quit [Ping timeout: 268 seconds]
fphilipe_ has quit [Ping timeout: 260 seconds]
felipec has joined #ruby
factormystic has joined #ruby
duderonomy has quit [Ping timeout: 260 seconds]
duderonomy has joined #ruby
im0nde_ has joined #ruby
donofrio_ has quit [Remote host closed the connection]
im0nde has quit [Ping timeout: 272 seconds]
raggi- has quit [Read error: Connection reset by peer]
Elundia has joined #ruby
gitter1234 has joined #ruby
raggi- has joined #ruby
Elundia has quit [Remote host closed the connection]
Elundia has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
<ytti> this may be bit of unwelcome golfing
<ytti> but suppose
<ytti> str.split(/\b/)
pwnd_nsfw has joined #ruby
<ytti> now i want to replace element #4 with some static string
<ytti> without returning and assigning the interim array first
<ytti> i could probably do it with map with index
<ytti> and check in the block which index i have, but that feels fugly
alexherbo21 has joined #ruby
alex`` has quit [Ping timeout: 240 seconds]
<ytti> basically swap element of array and return the new array
alexherbo2 has quit [Ping timeout: 272 seconds]
alexherbo21 is now known as alexherbo2
alex`` has joined #ruby
felipec has quit [Quit: Leaving]
Elundia has quit [Remote host closed the connection]
chalkmonster has quit [Ping timeout: 268 seconds]
howdoi has quit [Quit: Connection closed for inactivity]
sauvin has joined #ruby
lineus_ has joined #ruby
lineus has quit [Ping timeout: 240 seconds]
<Cork> is there something similar to File.join but where you can specify what os the path is for?
<Cork> (i'm building a windows path on a linux box)
smccarthy has quit [Remote host closed the connection]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ytti> &>> File.send(:remove_const, 'SEPARATOR');File.const_set('SEPARATOR', '\\');File.join("moi", "hei")
<rubydoc> # => "moi/hei" (https://carc.in/#/r/8f27)
<ytti> hmm
<ytti> i thought that would have worked
<Cork> looks like it should ya
<Cork> but are you usre join uses SEPARATOR?
<ytti> it doesn't seem to
<ytti> perhaps you should jsut use ary.join('\\')
<ytti> because aftrer all, your goal is not portability
<ytti> you explicitly want to generate windows format, always
<ytti> and File.join motivation is portability
chalkmonster has joined #ruby
<Cork> ya, but i also want to be careful with things like ..\\ and stuff like that in the strings i join
<ytti> File.join doesn't 'encode' the strings to be filesystem safe
<ytti> &>> File.join("mo/i", "hei")
<rubydoc> # => "mo/i/hei" (https://carc.in/#/r/8f29)
<Cork> huh, well ok then :)
<Cork> thought it did
zdm has quit [Remote host closed the connection]
pandakekok9 has quit [Quit: Overthrow the fascist Duterte regime! VIVA CPP-NPA-NDF!]
Keltia_ has joined #ruby
AndroidKK has joined #ruby
pelegreno___ has joined #ruby
NightMonkey_ has joined #ruby
Scripton1ut has joined #ruby
umjisus_ has joined #ruby
rprimus_ has joined #ruby
asio_ has joined #ruby
rprimus_ is now known as Guest78959
cjohnson_ has joined #ruby
IcyDragon has joined #ruby
bruce_lee has quit [Ping timeout: 268 seconds]
pwnd_nsfw has quit [*.net *.split]
sh7d has quit [*.net *.split]
ttoocs has quit [*.net *.split]
s2013 has quit [*.net *.split]
manveru has quit [*.net *.split]
davispuh has quit [*.net *.split]
jnoon has quit [*.net *.split]
BuildTheRobots has quit [*.net *.split]
ec has quit [*.net *.split]
gmcintire has quit [*.net *.split]
cadeskywalker has quit [*.net *.split]
Lyubo1 has quit [*.net *.split]
AndroidKitKat has quit [*.net *.split]
greypack has quit [*.net *.split]
ltp has quit [*.net *.split]
Xeago has quit [*.net *.split]
Cope has quit [*.net *.split]
PaulePanter has quit [*.net *.split]
Keltia has quit [*.net *.split]
dalpo has quit [*.net *.split]
justinmrkva has quit [*.net *.split]
rprimus has quit [*.net *.split]
IceDragon has quit [*.net *.split]
jacksoow has quit [*.net *.split]
eldritch has quit [*.net *.split]
cjohnson has quit [*.net *.split]
r29v has quit [*.net *.split]
arooni has quit [*.net *.split]
Nilium has quit [*.net *.split]
NightMonkey has quit [*.net *.split]
xMopx has quit [*.net *.split]
Davey has quit [*.net *.split]
umjisus has quit [*.net *.split]
pelegreno__ has quit [*.net *.split]
mahlon has quit [*.net *.split]
matled has quit [*.net *.split]
m17 has quit [*.net *.split]
adam12 has quit [*.net *.split]
asio has quit [*.net *.split]
j416 has quit [*.net *.split]
Scriptonaut has quit [*.net *.split]
eam has quit [*.net *.split]
tabakhase has quit [*.net *.split]
rcs has quit [*.net *.split]
phI||Ip has quit [*.net *.split]
cnomad has quit [*.net *.split]
m17- has joined #ruby
bruce_lee has joined #ruby
greypack has joined #ruby
j416 has joined #ruby
<gitter1234> Hi! Trying to make it so that only users approved by admin can post posts. Is this the way to do it? https://gist.github.com/1234dev/0f37e7935bf2efe85070bd1a7786d1a4
pizzaiolo has quit [Ping timeout: 240 seconds]
<gitter1234> 1) Should I put anything in routes.rb? 2) Should I toggle from the model instead? 3) I seem to be repeating myself a lot - could any of this be clean up? 4) The whole privilege-changing attributes being changed via mass-assignment - how do I prevent that?
dalpo has joined #ruby
ropeney_ has joined #ruby
bodqhrohro has quit [Ping timeout: 268 seconds]
bodqhrohro has joined #ruby
pizzaiolo has joined #ruby
ropeney has quit [Ping timeout: 268 seconds]
cadeskywalker has joined #ruby
akemrir has joined #ruby
umjisus_ is now known as umjisus
chalkmonster has quit [Quit: WeeChat 2.7]
<gitter1234> howdy akemrir! you left quite abruptly last night lol
houhoulis has quit [Remote host closed the connection]
<gitter1234> if you're still able to help - i tried adding has_one_attached :avatar but to no avail - https://gist.github.com/1234dev/94000c5202907e973949ae907bbac0c2
sergioro has quit [Quit: leaving]
gylpm has quit [Ping timeout: 272 seconds]
gylpm has joined #ruby
TomyWork has joined #ruby
BuildTheRobots has joined #ruby
pwnd_nsfw has joined #ruby
ttoocs has joined #ruby
davispuh has joined #ruby
gmcintire has joined #ruby
ec has joined #ruby
jnoon has joined #ruby
ltp has joined #ruby
Lyubo1 has joined #ruby
Xeago has joined #ruby
sh7d has joined #ruby
Cope has joined #ruby
cnomad has joined #ruby
justinmrkva has joined #ruby
PaulePanter has joined #ruby
matled has joined #ruby
adam12 has joined #ruby
jacksoow has joined #ruby
xMopx has joined #ruby
arooni has joined #ruby
manveru has joined #ruby
Davey has joined #ruby
Nilium has joined #ruby
eldritch has joined #ruby
rcs has joined #ruby
mahlon has joined #ruby
eam has joined #ruby
phI||Ip has joined #ruby
r29v has joined #ruby
tabakhase has joined #ruby
NODE has quit [Excess Flood]
xNetX0 has joined #ruby
fphilipe_ has joined #ruby
schne1der has joined #ruby
dionysus69 has joined #ruby
thecoffemaker has quit [Ping timeout: 268 seconds]
ropeney has joined #ruby
swistak35 has quit [Ping timeout: 240 seconds]
swistak35 has joined #ruby
thecoffemaker has joined #ruby
xNetX0 is now known as NODE
thecoffemaker has quit [Changing host]
thecoffemaker has joined #ruby
ropeney_ has quit [Ping timeout: 240 seconds]
gylpm has quit [Ping timeout: 240 seconds]
gylpm has joined #ruby
CustosLimen has joined #ruby
<CustosLimen> hi
<CustosLimen> where is the documentation for initialize/new
<akemrir> gitter1234: I know where you are creating error ;)
SqREL has joined #ruby
<akemrir> gitter1234: you are using has_one_attached and then later overwrite method avatar, new avatar method is returning string. New method shadows previous functionality.
<akemrir> gitter1234: it looks, you need to generate this identicon while/after avatar upload, then attach it, to be able to process it later
SqREL has quit [Quit: Textual IRC Client: www.textualapp.com]
mossplix has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gylpm has quit []
NODE has left #ruby [#ruby]
<havenwood> &>> Object.method(:new).owner
<rubydoc> # => Class (https://carc.in/#/r/8f2p)
NODE has joined #ruby
NODE has quit [Client Quit]
<CustosLimen> thanks havenwood
<havenwood> CustosLimen: you're welcome
conta has joined #ruby
NODE has joined #ruby
turbo_choo has quit [Ping timeout: 272 seconds]
turbo_choo has joined #ruby
jenrzzz has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
fphilipe_ has quit [Ping timeout: 272 seconds]
phaul has quit [Ping timeout: 272 seconds]
fphilipe_ has joined #ruby
fphilipe_ has quit [Ping timeout: 260 seconds]
dinfuehr has quit [Ping timeout: 272 seconds]
dinfuehr_ has joined #ruby
KeyJoo has joined #ruby
mossplix has quit [Ping timeout: 268 seconds]
kristian_on_linu has joined #ruby
Bounga has joined #ruby
<CustosLimen> so I have this: https://bpaste.net/V3WA
<CustosLimen> Whjen I run it I get https://bpaste.net/745Q (unknown keyword: argv)
<canton7> CustosLimen, on which line?
<CustosLimen> 78
ellcs has joined #ruby
conta has quit [Quit: conta]
<CustosLimen> I got it
<CustosLimen> somehow I'm passing an object
NODE has quit [Quit: changing servers]
NODE has joined #ruby
tsujp has joined #ruby
fphilipe_ has joined #ruby
fphilipe_ has quit [Ping timeout: 268 seconds]
phaul has joined #ruby
chalkmonster has joined #ruby
fphilipe_ has joined #ruby
fphilipe_ has quit [Ping timeout: 268 seconds]
dviola has joined #ruby
rippa has joined #ruby
gitter1234 has quit [Quit: Connection closed for inactivity]
fphilipe_ has joined #ruby
xco has joined #ruby
evdubs has quit [Quit: Leaving]
william1 has joined #ruby
pwnd_nsfw has quit [Remote host closed the connection]
evdubs has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
mossplix has joined #ruby
manj-gnome has joined #ruby
al2o3-cr has quit [Quit: WeeChat 2.7]
zdm has joined #ruby
<manj-gnome> guys i need help with this "bundle install
<manj-gnome> Could not locate Gemfile"
al2o3-cr has joined #ruby
tpanarch1st has quit [Ping timeout: 255 seconds]
kristian_on_linu has quit [Remote host closed the connection]
manj-gnome has quit [Client Quit]
fphilipe_ has quit [Ping timeout: 260 seconds]
fphilipe_ has joined #ruby
<phaul> manj.. oh
pandakekok9 has joined #ruby
tdy has quit [Read error: Connection reset by peer]
william1 has quit [Ping timeout: 268 seconds]
tdy has joined #ruby
BTRE has quit [Ping timeout: 265 seconds]
BTRE has joined #ruby
mossplix has quit [Remote host closed the connection]
RiPuk has quit [Quit: ZNC 1.7.5 - https://znc.in]
RiPuk has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
mossplix has joined #ruby
fphilipe_ has quit [Ping timeout: 268 seconds]
william1 has joined #ruby
fphilipe_ has joined #ruby
suukim has joined #ruby
RiPuk has quit [Ping timeout: 268 seconds]
RiPuk has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
RiPuk has quit [Ping timeout: 240 seconds]
RiPuk has joined #ruby
lineus_ is now known as lineus
mossplix has quit [Remote host closed the connection]
pandakekok9 has quit [Remote host closed the connection]
pandakekok9 has joined #ruby
cthu| has joined #ruby
donofrio has joined #ruby
cthulchu_ has quit [Ping timeout: 272 seconds]
mossplix has joined #ruby
phaul has quit [Ping timeout: 265 seconds]
Nahra has joined #ruby
william1 has quit [Ping timeout: 268 seconds]
voker57 has joined #ruby
mossplix has quit [Remote host closed the connection]
cd has joined #ruby
Mrbuck has quit [Quit: .]
AJA4350 has joined #ruby
gitter1234 has joined #ruby
<gitter1234> akemrir: hey just got back
mossplix has joined #ruby
pandakekok9 has quit [Ping timeout: 240 seconds]
pandakekok9 has joined #ruby
anveo has joined #ruby
emilych has joined #ruby
markopasha has joined #ruby
factormystic0 has joined #ruby
<gitter1234> akemrir: struggling to understand what i should do next. could you give any more pointers please?
sphex_ has joined #ruby
voker57 has quit [Ping timeout: 272 seconds]
sphex has quit [Ping timeout: 272 seconds]
factormystic has quit [Ping timeout: 272 seconds]
factormystic0 is now known as factormystic
phaul has joined #ruby
Nahra has quit [Quit: leaving]
dviola has quit [Quit: WeeChat 2.7]
phaul has quit [Ping timeout: 265 seconds]
stoffus has joined #ruby
phaul has joined #ruby
emilych has quit [Remote host closed the connection]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
fphilipe_ has quit [Ping timeout: 240 seconds]
tjbp_ is now known as tjbp
voker57 has joined #ruby
phaul has quit [Ping timeout: 240 seconds]
weeirc8087 has joined #ruby
xco has quit [Quit: Textual IRC Client: www.textualapp.com]
fphilipe_ has joined #ruby
phaul has joined #ruby
weeirc8087 has quit [Ping timeout: 240 seconds]
woodruffw has quit [Ping timeout: 258 seconds]
woodruffw has joined #ruby
woodruffw has quit [Changing host]
woodruffw has joined #ruby
pandakekok9 has quit [Quit: Overthrow the fascist Duterte regime! VIVA CPP-NPA-NDF!]
Omnilord has joined #ruby
weeirc8087 has joined #ruby
turbo_choo has quit [Ping timeout: 265 seconds]
woodruffw has quit [Ping timeout: 258 seconds]
stoffus has quit [Ping timeout: 265 seconds]
woodruffw has joined #ruby
woodruffw has quit [Changing host]
woodruffw has joined #ruby
fphilipe_ has quit [Ping timeout: 268 seconds]
alexherbo29 has joined #ruby
alex`` has quit [Ping timeout: 260 seconds]
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo29 is now known as alexherbo2
mossplix has quit [Remote host closed the connection]
alex`` has joined #ruby
jcalla has joined #ruby
<adam12> gitter1234: Reshare where you're at since I don't see it in the history.
lucasb has joined #ruby
<gitter1234> adam12: hey there. same problem as yesterday tho
<gitter1234> adam12: Anybody know why I'm getting `undefined method 'variant' for #String` when trying to pass an avatar to ActiveStorage for processing? https://gist.github.com/1234dev/94000c5202907e973949ae907bbac0c2
<adam12> gitter1234: Rename `avatar` method to something like `generate_avatar`
<adam12> gitter1234: Actually, get rid of the avatar method completely.
<adam12> gitter1234: When you refresh /posts, you should have a different error now?
thecoffemaker has quit [Read error: Connection reset by peer]
<gitter1234> adam12: yes indeedie-o! `variant delegated to attachment, but attachment is nil`
<adam12> gitter1234: Load up a Rails console, and try something like this: User.all.each { |user| user.save }
TCZ has joined #ruby
<gitter1234> adam12: NameError (undefined local variable or method `user' for #<User:0x00000fe044c063e8>)
<adam12> gitter1234: The backtrace should point to the callback you made?
<adam12> gitter1234: send_to_active_storage
weeirc8087 has quit [Ping timeout: 240 seconds]
<gitter1234> yes!
<gitter1234> yes it does
<adam12> gitter1234: Drop the user at the beginning. avatar.attach..therest
<adam12> gitter1234: Re-run the rails console command.
<gitter1234> its doing something.. my computer is extremely slow so its hard to tell (its been dropped on its head more times than a baby.. it was even involved in a street fight once.. has all kinds of dents on it). no errors so far tho
<gitter1234> User Load (2.1ms) SELECT "users".* FROM "users" and nothing more happens. i tried reloading in the browser but get the same error as previously
woodruffw has quit [Ping timeout: 240 seconds]
duderonomy has joined #ruby
<adam12> gitter1234: OK. I'd just try doing it manually without the callback and see if it works. Then go from there.
woodruffw has joined #ruby
woodruffw has quit [Changing host]
woodruffw has joined #ruby
weeirc8087 has joined #ruby
<adam12> gitter1234: user = User.first; user.avatar.attach(Identicon.blob_for(user.email))
<adam12> gitter1234: then check user.avatar.class
grilix has quit [Ping timeout: 252 seconds]
<gitter1234> adam12: not getting any response, laptop fan is spinning out of control. looks like some infinite loop thing idk
<gitter1234> ill get back to you once i figure out whats wrong!
turbo_choo has joined #ruby
fphilipe_ has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Inline has joined #ruby
<gitter1234> adam12: it just freezes at user.avatar.attach(Identicon.blob_for(user.email))
<adam12> gitter1234: OK. I'd probably start by looking at the attach method provided by ActiveSupport; what types of objects does it accept/expect? Maybe it doesn't like the Identicon blob.
<adam12> gitter1234: Try passing it a real file of something local. That way you can identify if the attach is working fine.
<gitter1234> great idea
<adam12> gitter1234: When I suggested that originally, I thought that blob might have been an issue because it's a string. You can wrap it in a StringIO object to make it look like an IO object and that _might_ make ActionStorage happy.
conta1 has joined #ruby
<adam12> And when I said ActiveSupport earlier, I meant ActiveStorage. or ActionStorage... I don't get Rails naming :)
grilix has joined #ruby
DaRock has quit [Ping timeout: 260 seconds]
mossplix has joined #ruby
<lmat> adam12: Ah, here's an article about rails autoloading (about which I was asking a little yesterday). I think it's telling that "hell" is the last word of the title ^_^ https://urbanautomaton.com/blog/2013/08/27/rails-autoloading-hell/
<adam12> lmat: Hah! Well in Rails 6, the autoloader is new with a new mechanism. It doesn't save you from hell directly, but it makes the process much nicer. I use Zeitwerk in some non-rails projects to much success.
<adam12> lmat: It's a sacrifice to be made for reloading, sadly. To perform an inprocess reload, the constant has to be undefined and the file it was loaded from removed from the array of files already required. This requires some constraints to keep things sane. But it does and can work around it by other means.
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
weeirc8087 has quit [Ping timeout: 265 seconds]
<lmat> adam12: Is there a built-in way to mock for unit tests?
<adam12> lmat: Rails ships with Minitest (so does Ruby, tbh). Minitest has Minitest::Mock.
<lmat> Okay, I'll start looking at minitest first.
phaul has quit [Ping timeout: 265 seconds]
woodruffw has quit [Ping timeout: 268 seconds]
<adam12> lmat: If this is an existing project it might be running rspec, which is another test framework.
<lmat> adam12: good idea. There isn't much code here yet, but I'll look at that.
<gitter1234> adam12: this looks ok right? still freezes... file = File.open(public/apple-touch-icon.png); user = User.first; user.avatar.attach(file)
phaul has joined #ruby
<gitter1234> "public/apple-touch-icon.png" in quotes rather
<adam12> gitter1234: Presuming you're quoting.
<lmat> adam12: What am I looking for? grep rspec *; and grep rspec test -ri; showed nothing
<gitter1234> yep
<gitter1234> :)
<adam12> gitter1234: Yeah. That looks perfect to me. Maybe look at your ActiveStorage settings? Is it trying to upload to S3 or something?
<gitter1234> will do, thanks!
<adam12> lmat: Normally it would be in your Gemfile. `rspec-rails`. If not, then you are using the Rails default which is minitest.
<lmat> adam12: sweet. I just looked through the tests. I'm pretty sure there's no mocking. Just calling "real" methods then asserting.
fangs2 has joined #ruby
<fangs2> hello
<fangs2> i'm a new user
<fangs2> gem always installs to a wrong architecture, any hints?
<lmat> adam12: ActionDispatch::IntegrationTest is that a tell?
<lmat> fangs2: What is it doing and what do you expect it to do?
<gitter1234> adam12: looks like a similar problem -- https://stackoverflow.com/questions/52274797/seeding-images-with-active-storage
<fangs2> i am trying gem install sha3
<adam12> lmat: Rails makes their own test classes for certain things, which include certain things (like the `get` method).
<fangs2> and I get compile errors, it wants to compile to x64 but im on arm64
<fangs2> if i correct the makefile, gem install seems to replace the makefile with the bad one
<adam12> gitter1234: Interesting.
<adam12> fangs2: The Makefile is autogenerated I'm guessing. You'd have to maybe adjust extconf.rb.
Omnilord has quit [Quit: Leaving]
<adam12> fangs2: What's the adjustment you're making anyways? Can you share it in a gist or paste?
<lmat> adam12: Ah, okay. I was liking using that. So if I move to minitest, I'll extend Minitest::Test and won't get "get" anymore?
<fangs2> good, thanks, is there an extconf.rb per gem?
<fangs2> I make no adjustment, only wanted to install
<adam12> lmat: Right. You'd have to bring in Rack::Test which is what `get` is from. `class Foo < Minitest::Test; include Rack::Test::Methods; end`
<lmat> adam12: Thanks!
* lmat looks up include vs require ^_^
<adam12> fangs2: There normally is. It's often in `ext/`. It will generate the Makefile. If it's not building on arm64 and can be fixed in the extconf.rb then it might be a good PR.
<fangs2> sorry but what do you mean with PR
<adam12> fangs2: Pull Request.
<fangs2> ah, I see
<fangs2> thanks I will try
<fangs2> the error came after bundle install
<fangs2> this bundle seems to be a mix of some packages
<fangs2> thanks a lot really
<adam12> fangs2: I'm guessing this is the line you're having issues with. https://github.com/johanns/sha3/blob/master/ext/sha3/extconf.rb#L20
<fangs2> some things you never find by a simple googling
<lmat> adam12: did the include, but now the route helpers don't work :-)
<adam12> lmat: There's a bunch of other stuff that has to happen; you'd have to define the `app` method to point to your Rails/Rack app. Definitely use the Rails conveniences if you're in Rails.
<fangs2> probably adam, I cant open the link right now, but I feel it will correct the problem
<adam12> fangs2: OK good luck!
<fangs2> thanks have a nice day
fangs2 has quit [Remote host closed the connection]
jenrzzz has joined #ruby
<lmat> adam12: Oh, I get the "test" keyword back when I extend ActiveSupport::TestCase. I'm not sure what that is, but ActiveSupport sounds so supportive of my efforts.
akemrir has quit [Quit: WeeChat 2.7]
<adam12> lmat: It's a DSL around defining methods. `def test(test_name, &block); define_method("test_#{test_name}", block); end`. Something like that but more complex (sanitizing test name into a valid method name, etc).
davor_ has joined #ruby
<lmat> adam12: sweet
<lmat> Oh, there's also ActionController::TestCase so many choices!
davor has quit [Ping timeout: 240 seconds]
davor_ is now known as davor
jenrzzz has quit [Ping timeout: 272 seconds]
fangs2 has joined #ruby
<fangs2> Hello again
<fangs2> Unfortunately, It didnt work
<fangs2> gem install seems to replace extconf.rb
<fangs2> and I get again arch errors on compile
<lmat> adam12: on https://semaphoreci.com/community/tutorials/mocking-in-ruby-with-minitest, I see "SubscriptionService.stub :new, mock do". It looks like there should be some static function, "stub", on the SubscriptionService, but where is it defined?
<fangs2> is there a way to install a gem manually or something?
cjohnson_ is now known as cjohnson
buckworst has joined #ruby
Swyper has quit [Remote host closed the connection]
KeyJoo has quit [Quit: KeyJoo]
TCZ has quit [Quit: Bye Bye]
Swyper has joined #ruby
poontangmessiah has joined #ruby
<adam12> lmat: That's part of Minitest. It adds a `stub` method to .. Object if I remember right.
<gitter1234> adam12: ive just been told i could also check the null object pattern for instances like that, does that make any sense to you? https://thoughtbot.com/blog/rails-refactoring-example-introduce-null-object
fphilipe_ has quit [Ping timeout: 240 seconds]
<adam12> fangs2: gem fetch sha3; gem unpack sha3-1.0.1.gem; cd sha3-1.0.1; vim ext/sha3/extconf.rb; rake build; gem install pkg/sha3-1.0.1.gem
<fangs2> I will try adam, thanks again
fangs2 has quit [Remote host closed the connection]
<adam12> gitter1234: I wouldn't. You should always have an avatar, since you're building them from an email address which you should also always have. No?
conta1 has quit [Quit: conta1]
fphilipe_ has joined #ruby
<adam12> gitter1234: Nothing wrong with the null object pattern but it's not going to solve your problem here.
<gitter1234> yep, should always be there..
<gitter1234> good to know :)
<adam12> gitter1234: Maybe this is a problem with spring. Try shutting down your entire Rails app (making sure to shut it down via spring) then start it again.
<adam12> gitter1234: Sometimes Spring/Rails holds on to things longer than it should.
<gitter1234> hehe.. i just disabled that actually because i had some bad experience with it in the past. also i noticed that it spawned several different processes when running rails console so
<adam12> gitter1234: Then from there, try just attaching that normal file you were doing earlier. If it's still in deadlock.. I'm not sure.
<adam12> gitter1234: Ah OK. Did that StackOverflow post not yield anything fruitful? I only glanced over it.
ellcs has quit [Ping timeout: 240 seconds]
<gitter1234> nah just a buncha comments that led nowhere
<lmat> adam12: sweet!
<lmat> adam12: (regarding .stub)
<adam12> lmat: If you look at the ancestors of those test classes, I bet they're related. ActiveSupport::TestCase is probably an ancestor of ActionDispatch::IntegrationTest. You can see it in the Rails console likely. ActionDispatch::IntegrationTest.ancestors
ellcs has joined #ruby
duderonomy has joined #ruby
fangs2 has joined #ruby
<fangs2> sorry , more errors
<fangs2> Invalid gemspec in sha3.gemspec: no such file or directory
<fangs2> after "rake build"
<lmat> adam12: Also in "SubscriptionService.stub :new, mock do" what does ":new" mean? I think I understand colon-variables, but is ":new" a predefined minitest constant, or does it mean "mack the "new" function? Or does it mean "make a new mock"?
<lmat> heh s/mack/mock
<lmat> smack the mack to a mock
<adam12> fangs2: I'm not sure how much more I'll be able to help you blindly. If you can share the output in a gist or dpaste then maybe we can look. But I built it fine here since I was curious (I'm on x86_64 tho)
<adam12> lmat: It mocks the `new` method on SubscriptionService.
<fangs2> sorry, I cant paste or dont know how, im on a cli app
<adam12> lmat: The colon-variable is called a symbol, fyi.
<lmat> adam12: Ah, symbol, thanks. So if I wanted to mock the "initialize" function (constructor) of an object, I might MyClass.stub :initialize, mock do.. ?
<adam12> lmat: Initialize is a special case. You'd want to mock `new`.
<adam12> lmat: It's the only special case (AFAIK).
<lmat> adam12: thanks!
<lmat> adam12: Just to keep straight, obj = MyObject.new; calls MyObject's "def initialize", right?
ellcs has quit [Remote host closed the connection]
<lmat> then obj.new calls MyObject's "def new"
<adam12> lmat: Yes for the first; but tbh, I've never seen `new` defined on a class before, so I presume it would work as it's not defined on the eigenclass, but it's unexpected in Ruby because it's somewhat abiguous.
<lmat> adam12: I think it's not ambiguous because "new" is an (non-static) member function, but "initialize" is a static member function.
<adam12> lmat: Well I guess it depends on your team. If I'm working with juniors, I'd prefer less ambiguity and wouldn't permit `new` as an instance method. But there's nothing stopping you AFAIK with Ruby being concerned.
<lmat> adam12: I see, thank you.
<adam12> gitter1234: Are you attaching files elsehwerE? Just the avatar causing you grief?
anveo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<gitter1234> just avatar.. i have regular photo uploads and its working fine..
<gitter1234> my post model has: has_many_attached :images
<fangs2> OK, I managed to build it, after correcting gemspec, what was the final step after that?
<adam12> gitter1234: what happens when you tell it to not identify the attachment? user.avatar.attach(file, identify: false)
<adam12> fangs2: gem install pkg/sha3-1.0.1.gem
<adam12> gitter1234: Do you make your own attachments table in a migration? or is that handled for you?
<lmat> My class uses params.require(:transaction)... How can I prepare for this in a unit test?
<gitter1234> adam12: it was made with active_storage:install yeah
<fangs2> success adam, thank you
<adam12> fangs2: cheers!
<gitter1234> adam12: well look at that.. no freeze!
<adam12> gitter1234: I wonder if it uses imagemagick or graphicsmagick to identify files...
<gitter1234> ArgumentError (wrong number of arguments (given 2, expected 1)) though
<adam12> gitter1234: For that line? Ah
TCZ has joined #ruby
<adam12> gitter1234: attach(io: file, identify: false)
<adam12> That's annoying.
<gitter1234> yeah it uses imagemagick afaik... i tried to switch to the new vips but my OS doesn't support its dependencies so..
<gitter1234> cool :)
<adam12> If that still dies it's probably not imagemagick..
<gitter1234> it freezes :/
<adam12> gitter1234: what OS?
<gitter1234> openbsd
<gitter1234> i could perhaps get it working.. its supposed to be a LOT faster than imagemagick
<gitter1234> should i give it a go?
<adam12> gitter1234: VIPS? I mean it's great. I use it on my image optimizing service Slimpixels, but I don't think it's your problem here.
<adam12> gitter1234: Can you check process tree when it freezes? `ps aux` or something? Maybe there's something obvious.
<gitter1234> wow! you have.. wow :)
<gitter1234> okay sure
<adam12> gitter1234: Maybe this is an Openbsd bug...
<gitter1234> wait despite the freeze i was able to ctrl+c it this time
TCZ has quit [Quit: Bye Bye]
<adam12> gitter1234: Actually, disregard that. You have uploads working.
<gitter1234> i should probably get vips working regardless
<adam12> gitter1234: Oh interesting.
<adam12> gitter1234: Remove the callback from the model.
<gitter1234> damn man your site is freakin' gorgeous!
<adam12> gitter1234: You can leave the method definition, just comment out `before_save`
<gitter1234> i had to look it up sorry
<gitter1234> lol
<gitter1234> ok lets try that.
weeirc8087 has joined #ruby
<adam12> gitter1234: Probably wrong site. Slimpixels is API only (slimpixels.com
<gitter1234> oh :) well if you ever need a website layout and logo i'd be happy to help
<gitter1234> i cant promise anything but i always try to be on par with https://gestalten.com/products/los-logos-8 etc.
buckworst has quit [Quit: WeeChat 2.7]
d^sh has joined #ruby
<gitter1234> ok no freeze this time, just: ArgumentError (missing keyword: filename)
<adam12> gitter1234: Are you using the new or old attach mechanism? I'd switch back to the old version (user.avatar.attach(file))
TCZ has joined #ruby
<gitter1234> ooooh... check this out!
<gitter1234> or, well, ArgumentError (Could not find or build blob: expected attachable, got #<File:public/apple-touch-icon.png>)
<gitter1234> using file = File.open("public/apple-touch-icon.png"); user = User.first; user.avatar.attach(file)
weeirc8087 has quit [Ping timeout: 268 seconds]
<adam12> gitter1234: See if you can take it from here; and then circle back to fix the callback.
unixabg has left #ruby [#ruby]
<gitter1234> ill do my best!
d^sh has quit [Ping timeout: 265 seconds]
GodFather has joined #ruby
<lmat> I think the answer to the params problem is: don't unit test controllers. Controllers should be tested with integration tests.
meinside has quit [Quit: Connection closed for inactivity]
<adam12> lmat: If you haven't given the Rails guide a read I encourage you to do so. Especially around testing, since everyone seems to have a slightly opinion of what constitutes a test of what sort, and Rails doesn't differ in that it has it's own opinion.
fangs2 has quit [Remote host closed the connection]
<lmat> adam12: okay, thank you!
ttoocs has quit [Ping timeout: 268 seconds]
TomyWork has quit [Remote host closed the connection]
<lmat> adam12: By the way, the new function is created by rails generate.
<adam12> lmat: I don't follow.
<lmat> https://youtu.be/OaDhY_y8WTo?t=323 See the new function there? It was generated automatically by rails generate: https://youtu.be/OaDhY_y8WTo?t=71
<lmat> I don't mean to contradict you; it may be a bad idea. All I'm saying is that it's default and common.
<lmat> (bad idea for junior devs: it's ambiguous with the "new" constructor call)
<lmat> "do" always introduces a lambda function? (And lambda function parameters between pipes, got it!)
TCZ has quit [Quit: Bye Bye]
turbo_choo has quit [Ping timeout: 265 seconds]
weeirc8087 has joined #ruby
abe has joined #ruby
mossplix has quit [Remote host closed the connection]
davidw has joined #ruby
davidw has quit [Changing host]
davidw has joined #ruby
phaul has quit [Ping timeout: 272 seconds]
mossplix has joined #ruby
wildtrees has joined #ruby
Swyper has quit [Remote host closed the connection]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
davidw has quit [Ping timeout: 272 seconds]
alexherbo24 has joined #ruby
alexherbo2 has quit [Ping timeout: 260 seconds]
alexherbo24 is now known as alexherbo2
fphilipe_ has quit [Ping timeout: 268 seconds]
alex`` has quit [Ping timeout: 268 seconds]
howdoi has joined #ruby
alex`` has joined #ruby
<lmat> /win 1
chalkmonster has joined #ruby
poontangmessiah has quit [Ping timeout: 265 seconds]
Swyper has joined #ruby
woodruffw has joined #ruby
woodruffw has quit [Changing host]
woodruffw has joined #ruby
phaul has joined #ruby
Pika has joined #ruby
<Pika> I'm trying to use XML builder.... I put a stacktrace into one of my like builder.tags(stackTrace), but I want to escape all the <> and other such non XML safe characters. How would I do this?
<gitter1234> speaking of slimpixels, strange coincidence watching queen & slim right now just downloaded the torrent, it's one of those rare ones that you can tell is gonna be good after just a few seconds in
<Pika> https://github.com/jimweirich/builder I tried reading the documentation here.... but! the escape and unescape section doesn't seem to make sense to me since it looks like it's just putting as an attribute and not into the body
<Pika> it also says something like the body should be automatically escaped, but it seems to not be the case?
tdy has quit [Remote host closed the connection]
vondruch has joined #ruby
phaul has quit [Ping timeout: 260 seconds]
davidw has joined #ruby
davidw has joined #ruby
davidw has quit [Changing host]
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
alexherbo23 has joined #ruby
alex`` has quit [Ping timeout: 265 seconds]
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo23 is now known as alexherbo2
jaequery has joined #ruby
jenrzzz has joined #ruby
alex`` has joined #ruby
<Pika> Alternatively how what's the most performant way right now to encode some html stuff from like <> to the &whatever; characters
gray_-_wolf has joined #ruby
<al2o3-cr> Pika: do you want quotes escaping too?
<al2o3-cr> &>> "<?xml version=\"1.0\"?>\n<root>".encode(xml: :text)
<rubydoc> # => "&lt;?xml version=\"1.0\"?&gt;\n&lt;root&gt;" (https://carc.in/#/r/8f8p)
<al2o3-cr> &>> "<?xml version=\"1.0\"?>\n<root>".encode(xml: :attr) # for quotes
<rubydoc> # => "\"&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;root&gt;\"" (https://carc.in/#/r/8f8q)
<Pika> I actually don't know to be honest...
<Pika> My main concern is like... I'm dumping the StackTrace into <xml>StackTrace</xml> so I don't want any of the >whatever <stuff characters to be interpreted as further XML
sgen has joined #ruby
<adam12> lmat: Ohh! I forgot Rails uses the `new` method as an action. Yes! OK, that's one place I've seen it.
<Pika> The nekogiri builder doesn't look much different from the other 'builder' imo... what makes it better? =X
<al2o3-cr> not better, just my preference ;)
<adam12> Pika: Nokogiri is _possibly_ faster since it uses libxml2. Obviously you'd want to do your own benchmarks.
<adam12> Pika: Maybe you could use `CGI.escapeHTML(stackTrace)`
<lmat> gem uninstall --all; doesn't work. it says: "ERROR: While executing gem ... (NameError)\nuninitialized constant Gem::RDoc"
<lmat> I may have borked my gem installation by installing things concurrently :-/
<lmat> I'm thinking I should remove everything and start over. Alternatively, maybe there's some way to reinstall without removing? I don't care.
<adam12> lmat: The're installed in a folder. You could try just rm'ing the folder.
<adam12> lmat: `gem env` and look for GEM PATHS
<al2o3-cr> lmat: "gem i rdoc" first
phaul has joined #ruby
<Pika> I'll try that, thank you!
mossplix has quit [Read error: Connection reset by peer]
<lmat> adam12: I was worried that some accounting would be off that way...
mossplix has joined #ruby
<adam12> lmat: Maybe; but if you're going nuclear enough to remove everything and start over, might as well try one step just below it.
<adam12> lmat: Could try re-installing rdoc as well, like al2o3-cr mentioned.
<lmat> Yeah, I installed rdoc, and got much further. Now I get "You don't have write permissions for the /usr/lib/ruby/gems/2.7.0 directory."
phaul has quit [Ping timeout: 272 seconds]
turbo_choo has joined #ruby
Swyper has quit [Remote host closed the connection]
mossplix has quit [Remote host closed the connection]
<al2o3-cr> lmat: you on arch linux?
<lmat> al2o3-cr: fo sho
<lmat> I think running sudo gem uninstall -all; would be a bad idea from what I've read online.
<al2o3-cr> lmat: did you add: PATH="$PATH:$(ruby -e 'puts Gem.user_dir')/bin"
<lmat> (though I would then have permission to write to /usr/lib/ruby/gems/2.7.0 and everywhere else...)
<lmat> al2o3-cr: I hard-coded the path, but it should come out to the same thing, let me see.
<lmat> yeah, that's on my path.
<lmat> al2o3-cr: It went through a lot of packages before giving that error.
<al2o3-cr> lmat: pastebin 'gem env'
<lmat> A bunch of "... depends on ...If you remove this gem..."
<al2o3-cr> lmat: add: export GEM_HOME=$HOME/.gem
<lmat> okay!
<lmat> to .bashrc?
<al2o3-cr> yes
mossplix has joined #ruby
<al2o3-cr> or .profile if it's interactive
<lmat> addressable is not installed in GEM_HOME,
<al2o3-cr> lmat: how did you install addressable?
<al2o3-cr> lmat: using pacman?
<lmat> I've only installed one gem: rails. Maybe I'll just try to uninstall that. Maybe addressable comes pre-installed or something.
<lmat> Successfully uninstalled rails-6.0.2.1
<lmat> Now I want to get the packages that were installed to support rails...
chalkmonster has quit [Ping timeout: 268 seconds]
TCZ has joined #ruby
<AndroidKK> if i've got an array that contains pairs of numbers, what would be the best way to delete an entire pair if one of the numbers in the pair is above a certain value? sorry for any messy code: https://waifupaste.moe/raw/tE.txt
<lmat> al2o3-cr: Well, I'll just keep working and see if everything works now properly ^_
<al2o3-cr> lmat: it should do now.
<lmat> al2o3-cr: cool
<al2o3-cr> make sure to restart your terminal
<al2o3-cr> to take effect.
<al2o3-cr> lmat: actually, yes restart, then pastebin 'gem env' again.
oncall-pokemon has joined #ruby
<adam12> AndroidKK: First; almost everywhere you're using sort! and uniq! you probably want their non-bang version (sort and uniq).
<adam12> AndroidKK: What's the certain value? where does it come from?
AJA4351 has joined #ruby
<lmat> al2o3-cr: it's going good!
<adam12> AndroidKK: The easiest solution is: pair.any? {|n| n > THRESHOLD }
<lmat> I'm following a tutorial. It generated an integration test and the setup action is: "@post = posts(:one)"
<lmat> Where is "posts" defined?
AJA4350 has quit [Ping timeout: 240 seconds]
AJA4351 is now known as AJA4350
Swyper has joined #ruby
<lmat> The class is PostsController < ApplicationController so I don't think it's in the superclass.
<lmat> The reason I ask about "posts" is because I want to know how it interprets ":one".
jenrzzz has quit [Ping timeout: 265 seconds]
<lmat> I ran ruby; and typed posts(:one)\n^d and it said exactly what I'm thinking; "undefined method `posts' for main:Object (NoMethodError)" At least someone is sane around here ^_
<lmat> I did the same thing in irb and it says the same thing :-)
<lmat> I learned Python a couple weeks ago and it wasn't too bad. This is really frustrating!
<lmat> I keep thinking, I'll just look at a beginners' tutorial to get started, but they really suck (at least for me).
<lmat> They say "look how easy this is! just type posts(:one) and it gets one post! wowie!" without telling what's happening :(
Swyper has quit [Remote host closed the connection]
<al2o3-cr> &>> [[10,20],[30,40],[50,60],[70,80]].reject { |pr| pr.any? { |n| n > 75 } }
<rubydoc> # => [[10, 20], [30, 40], [50, 60]] (https://carc.in/#/r/8f8v)
<al2o3-cr> ^AndroidKK:
<adam12> lmat: Have you used pry yet?
<al2o3-cr> &>> chk = -> (n) { n > 75 }; [[10,20],[30,40],[50,60],[70,80]].reject { |pr| pr.any? &chk }
<rubydoc> # => [[10, 20], [30, 40], [50, 60]] (https://carc.in/#/r/8f8w)
<adam12> lmat: Also, when you say learned Python; you mean just Python and not Django or something? Because right now you're learning Rails and not Ruby. Rails has many conveniences which you need to learn. That's not directly related to Ruby.
<lmat> adam12: pry, right, thanks for reminding me.
<lmat> adam12: Good point. I learned flask hand in hand with python. Web frameworks are often pretty invasive (changing the way the language feels) and rails seems particularly invasive.
<adam12> lmat: Call binding.pry beside the line you're curious on. Once you're there, use the `?` pry helper to look at things. try `? posts`.
<al2o3-cr> that any? should of been in the lambda, oh well.
<adam12> lmat: For Flask equivalent you'd be in Sinatra or Roda land. But neither of them afford you many conveniences out of the box (and Roda explicitely forces you to configure it how you want it through it's plugin system)
weeirc8087 has quit [Ping timeout: 240 seconds]
<al2o3-cr> &>> chk = -> (pr) { pr.any? { |n| n > 75 } }; [[10,20],[30,40],[50,60],[70,80]].reject &chk
<rubydoc> # => [[10, 20], [30, 40], [50, 60]] (https://carc.in/#/r/8f8x)
<al2o3-cr> lmat: yeah, pry is useful.
<lmat> adam12: okay, will do!
<adam12> lmat: Pry is your best tool to learn. There's some screencasts on the pry website that talk about inspecting objects (`cd`, `ls`, etc). It's very powerful.
<lmat> When trying to run rails test; I get "cannot load such file -- pry" I did gem install pry; before running rails test; I have require 'pry' at the top of my test.
<adam12> lmat: It will need to be part of your Gemfile. In Rails, use `pry-rails` as the gem name, which will make your rails console load pry too.
suukim has quit [Quit: Konversation terminated!]
<lmat> adam12: "cannot load such file -- pry-rails" I gem install pry-rails; and it says it installed one gem, but still no cigar.
<adam12> lmat: It has to be in your Gemfile.
<adam12> lmat: And skip any `require` that you're doing. Rails will do that for you (it's one of the Rails conveniences).
<lmat> okay, thanks!
sphex_ is now known as sphex
<lmat> adam12: Got it! Thanks again! When it broke on the pry binding call, it printed the call site like 8 times. Oh well :-)
chalkmonster has joined #ruby
houhoulis has joined #ruby
fphilipe_ has joined #ruby
sauvin has quit [Ping timeout: 272 seconds]
cadeskywalker has quit [Ping timeout: 258 seconds]
fphilipe_ has quit [Ping timeout: 252 seconds]
TCZ has quit [Quit: Bye Bye]
Nahra has joined #ruby
sgen has quit [Ping timeout: 240 seconds]
<lmat> adam12: You've been so helpful, thank you! al2o3-cr you, too!!
<adam12> lmat: cheers! and good luck.
<al2o3-cr> ;) np
lineus has quit [Remote host closed the connection]
lineus has joined #ruby
cadeskywalker has joined #ruby
axsuul has quit [Ping timeout: 258 seconds]
<lmat> FOUND IT!!! It's a fixture and defined in ./test/fixtures/posts.yml
troulouliou_dev has quit [Quit: Leaving]
<lmat> This reminds me a bit of java (spring boot). A little spaghetti-ish ^_^ I'm sure after I know all the little conventions and gotchas, it will be very comfortable. It's very uncomfortable now ;-)
<lmat> I found it using pry-nav and stepping into the posts function and inspecting all the variables.
Xiti` has joined #ruby
Xiti has quit [Ping timeout: 260 seconds]
axsuul has joined #ruby
subfj has joined #ruby
shirak_ has joined #ruby
anveo has joined #ruby
ctOS has joined #ruby
xxdxxd has joined #ruby
gix has joined #ruby
Bounga has quit [Ping timeout: 272 seconds]
xxdxxd has quit [Quit: xxdxxd]
xxdxxd has joined #ruby
gix- has joined #ruby
gix has quit [Disconnected by services]
Pika has quit [Remote host closed the connection]
brool has joined #ruby
tdy has joined #ruby
subfj has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ursu has joined #ruby
mokha has joined #ruby
<gitter1234> Hello! Trying to make it so that only users approved by admin can post posts. I've created a corresponding controller action which I'm attempting to call from the view, but how come I'm getting undefined method? https://gist.github.com/1234dev/0f37e7935bf2efe85070bd1a7786d1a4
mossplix has quit [Remote host closed the connection]
subfj has joined #ruby
phaul has joined #ruby
weeirc8087 has joined #ruby
yokel has quit [Ping timeout: 272 seconds]
Ai9zO5AP has quit [Quit: WeeChat 2.5]
bvdw has quit [Quit: bvdw]
<leftylink> don't think it's possible to tell from that code, since we don't see any calls to toggle_approved there, only the definition
bvdw has joined #ruby
jenrzzz has joined #ruby
yokel has joined #ruby
subfj has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mossplix has joined #ruby
<gitter1234> leftylink: sorrry its kinda messy, fixing it up now. "toggle_authorized" is supposed to be "toggle_approved"
sameerynho has joined #ruby
<gitter1234> also making a route
<lmat> I'm seeing undefined method log_in_as in my integration test. https://stackoverflow.com/questions/37173150 makes reference to it, but I can't find any documentation for log_in_as in the rails docs.
<lmat> Oh, ... maybe I'm supposed to write that method!
mossplix has quit [Ping timeout: 272 seconds]
AJA4350 has quit [Ping timeout: 272 seconds]
Jonopoly has joined #ruby
Fernando-Basso has joined #ruby
tpanarch1st has joined #ruby
subfj has joined #ruby
AJA4350 has joined #ruby
<adam12> gitter1234: Forget about using `helper_method :toggle_approved`. It's not needed.
lineus has quit [Ping timeout: 240 seconds]
weeirc8087 has quit [Ping timeout: 258 seconds]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<adam12> gitter1234: Your link_to in the view should have a route helper for the second argument, taking the _user_ as the argument (not the current_user, lest you want to disable yourself)
lineus has joined #ruby
subfj has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
oncall-pokemon has quit [Quit: Connection closed for inactivity]
FernandoBasso has joined #ruby
Fernando-Basso has quit [Ping timeout: 240 seconds]
AJA4350 has quit [Ping timeout: 265 seconds]
mossplix has joined #ruby
<gitter1234> adam12: hehe.. no id try to minimize self-damage as much as possible :) if you'd kindly reload https://gist.github.com/1234dev/0f37e7935bf2efe85070bd1a7786d1a4
Jonopoly has quit [Quit: WeeChat 2.5]
ellcs has joined #ruby
Bounga has joined #ruby
zapata has quit [Ping timeout: 246 seconds]
Bounga has quit [Ping timeout: 260 seconds]
<gitter1234> * i try to
<gitter1234> its looking pretty nice and clean now
mossplix has quit [Remote host closed the connection]
<gitter1234> adam12 you've been in here helping people all day lol. you deserve the rest of the day off :D and a medal of honor :D and cases upon cases upon cases of beer
subfj has joined #ruby
mossplix has joined #ruby
subfj has quit [Client Quit]
Nahra has quit [Quit: leaving]
Swyper has joined #ruby
<lmat> What's the normal way to log in during an integration test?
<lmat> I've tried several things...maybe I need to put a password hash in my fixture? yuck
<lmat> hmm...maybe I can set the session information on my first requets...
Pika has joined #ruby
<Pika> More builder questions D:
<Pika> Is there like... a way to add attributes to an XML tag after the fact or from inside the { |xml| curly brace thingies }
cd has quit [Quit: cd]
lucasb has quit [Quit: Connection closed for inactivity]
Swyper has quit [Remote host closed the connection]
abe has quit [Quit: Leaving]
<gitter1234> adam12: for what its worth, this seemed to work: user = User.first; user.avatar.attach(io: File.open('public/apple-touch-icon.png'), filename: 'apple-touch-icon.png')
<gitter1234> adam12: yielded the following: https://gist.github.com/1234dev/94000c5202907e973949ae907bbac0c2
awebdev has joined #ruby
awebdev has quit [Remote host closed the connection]
thecoffemaker has joined #ruby
ursu has quit [Remote host closed the connection]
brool has quit [Quit: WeeChat 2.7]
ellcs has quit [Ping timeout: 252 seconds]
Swyper has joined #ruby
DaRock has joined #ruby
ctOS has quit [Quit: Connection closed for inactivity]
troulouliou_dev has joined #ruby
houhoulis has quit [Remote host closed the connection]
sameerynho has quit [Quit: WeeChat 2.6]
fphilipe_ has joined #ruby
fphilipe_ has quit [Ping timeout: 260 seconds]
i_dont_do_spam has joined #ruby
xxdxxd has quit [Ping timeout: 265 seconds]
sergioro has joined #ruby
Bounga has joined #ruby
i_dont_do_spam has left #ruby [#ruby]
turbo_choo has quit [Ping timeout: 268 seconds]
Bounga has quit [Ping timeout: 245 seconds]
zapata has joined #ruby
GodFather has quit [Ping timeout: 272 seconds]