jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
swaggboi_ has joined #ruby
swaggboi_ has quit [Client Quit]
ur5us has quit [Ping timeout: 244 seconds]
bocaneri has joined #ruby
mossplix has quit [Ping timeout: 256 seconds]
CrazyEddy has quit [Ping timeout: 246 seconds]
baojg has quit [Remote host closed the connection]
ur5us has joined #ruby
zacts has joined #ruby
baojg has joined #ruby
zer0x2b has joined #ruby
<zer0x2b>
Hey guys. I'm not sure if I should ask this here or in rails (because attribute is a rails thing), but I'm having an issue with class << self, and accessing attributes of the parent function from within it. Is there a good way of doing this? Here's a snippet of what I mean: https://dpaste.org/jeCF
drincruz has joined #ruby
<zer0x2b>
(Note: Attribute is just a class attribute, not a column in the database)
<zer0x2b>
From what I have tried. When I'm trying to access y, from within the class << self block, it says it doesn't exist
<adam12>
zer0x2b: That seems right
<adam12>
zer0x2b: What are you trying to do at a higher level? do you have any real code you could share?
<zer0x2b>
My issue exists with trying to access it from within the class << self block.
<adam12>
zer0x2b: How are you trying to access it.
<zer0x2b>
Unfortunately I can't share the code. The gist is that I'm trying to have a flag on the parent that I can toggle from within a function. The function lives within the `class << self` block.
<zer0x2b>
I'm updating existing code, so I'm not sure the reasoning behind having the `class << self` block, but am trying to figure out how to work around it
<adam12>
zer0x2b: Not much to go on :\ `class << self` inside of a class is a re-opening of the Eigenclass or Singleton class. So if you had `class Foo`, you'd be re-opening the class and defining class methods.
<adam12>
zer0x2b: The `attribute` class method from Rails defines _instance_ methods. So if you do `class << self`, you need to then get an _instance_ of your class before attempting to use something you've defined using `attribute`.
<zer0x2b>
Ah, in the function within `class << self` it does a `create!` the the end of it. I'm guessing that would be creating the instance right? If that's the case, could I also use that create function to set the attribute?
<adam12>
zer0x2b: create! will return an instance, yes. So you could `foo = create!; foo.x = your_value; foo`. There's more concise ways of doing it but that might get you unstuck.
mossplix has joined #ruby
<zer0x2b>
Do you know if I could do something like `create!(params, y: 6)`?
<adam12>
zer0x2b: _maybe_. I don't use Rails so I'm not sure of the API or what `attribute` offers you.
<adam12>
zer0x2b: You'd probably need something like `create!(params.merge({y: 6})` tho
<zer0x2b>
Gotcha, well this at least points me in the right direction. Thank you so much for helping me even though I couldn't provide that much!
<adam12>
zer0x2b: No problem. Good luck.
zacts has quit [Quit: WeeChat 2.8]
mossplix has quit [Ping timeout: 264 seconds]
howdoi has quit [Quit: Connection closed for inactivity]
aurelius has joined #ruby
aurelius has quit [Ping timeout: 265 seconds]
rose_nd_ash has joined #ruby
wymillerlinux has quit [Ping timeout: 264 seconds]
braincrash has quit [Quit: bye bye]
_whitelogger has joined #ruby
braincrash has joined #ruby
wymillerlinux has joined #ruby
aurelius has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bambanx has quit [Quit: Leaving]
cyrus_mc_ has joined #ruby
orbyt_ has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]
rose_nd_ash has quit [Ping timeout: 256 seconds]
imode has quit [Quit: WeeChat 2.8]
imode has joined #ruby
imode has quit [Client Quit]
imode has joined #ruby
cyrus_mc_ has quit [Ping timeout: 246 seconds]
zer0x2b has quit [Remote host closed the connection]
alfiemax has joined #ruby
imode has quit [Quit: WeeChat 2.8]
imode has joined #ruby
ChmEarl has quit [Quit: Leaving]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
donofrio has quit [Remote host closed the connection]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
howdoi has joined #ruby
rose_nd_ash has joined #ruby
drincruz has quit [Ping timeout: 240 seconds]
alfiemax has quit [Ping timeout: 256 seconds]
alfiemax has joined #ruby
rose_nd_ash has quit [Remote host closed the connection]
rose_nd_ash has joined #ruby
rose_nd_ash has quit [Remote host closed the connection]
rose_nd_ash has joined #ruby
alfiemax_ has joined #ruby
wymillerlinux has quit [Ping timeout: 246 seconds]
alfiemax has quit [Ping timeout: 256 seconds]
rose_nd_ash has quit [Remote host closed the connection]
rose_nd_ash has joined #ruby
rose_nd_ash has quit [Remote host closed the connection]
rose_nd_ash has joined #ruby
mozzarella has quit [Remote host closed the connection]
mozzarella has joined #ruby
mossplix has joined #ruby
mossplix has quit [Ping timeout: 260 seconds]
_whitelogger has joined #ruby
rose_nd_ash has quit [Remote host closed the connection]
alfiemax_ has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 260 seconds]
_whitelogger has joined #ruby
RiPuk has quit [Ping timeout: 240 seconds]
schne1der has joined #ruby
RiPuk has joined #ruby
jetchisel has joined #ruby
mossplix has joined #ruby
rose_nd_ash has quit [Remote host closed the connection]
rose_nd_ash has joined #ruby
RiPuk has quit [Ping timeout: 264 seconds]
RiPuk has joined #ruby
mossplix has quit [Remote host closed the connection]
baojg has quit [Remote host closed the connection]
_whitelogger has joined #ruby
skape has quit [Quit: Connection closed for inactivity]
vondruch has joined #ruby
mossplix has joined #ruby
dviola has quit [Quit: WeeChat 2.9]
vondruch has quit [Client Quit]
vondruch has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
vondruch has quit [Read error: Connection reset by peer]
vondruch has joined #ruby
vondruch has quit [Client Quit]
vondruch has joined #ruby
imode has quit [Ping timeout: 240 seconds]
Secret-Fire has quit [Remote host closed the connection]
baojg has joined #ruby
Secret-Fire has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
konsolebox has quit [Read error: Connection reset by peer]
rdash has joined #ruby
TomyWork has joined #ruby
rose_nd_ash has quit [Ping timeout: 246 seconds]
konsolebox has joined #ruby
Fuzzy76 has joined #ruby
<Fuzzy76>
How can I do the following while also checking if userinfo returns nil? email = Ldap.userinfo(@uat.user)[:mail].first
<leftylink>
hmm. well the &. form of indexing is to use [] as a method. so that'd be &.[](:mail)
alfiemax has joined #ruby
<leftylink>
I made assumption sabout what "chekcing of userinfo returns nil" meant.
<leftylink>
I apologise if I assumed wrongly
<Fuzzy76>
That assumption was correct. The problem is that the server this runs on has ruby 2.0 so &. is off the table :-/
<Fuzzy76>
are these lines the equivalent?
alfiemax has quit [Remote host closed the connection]
<Fuzzy76>
ldap_info = ldap.userinfo(@uat.user)
<Fuzzy76>
email = ldap_info[:mail].first
vondruch_ has joined #ruby
<Fuzzy76>
(if so, the if is obvious to me)
<leftylink>
yes, by splitting it into mutiple lines, the course of action should be obvious enough
<leftylink>
to do it with one line... there is a possibility, but whether it is acceptable will be left to the preferences of those who will have to read it in the future
<Fuzzy76>
thanks, I was unsure wether the second line made sense like that. Ruby's syntax is very new to me (this is an inherited legacy codebase)
vondruch has quit [Ping timeout: 265 seconds]
vondruch_ is now known as vondruch
rdash has quit [Remote host closed the connection]
elphe has quit [Ping timeout: 260 seconds]
TomyWork has quit [Ping timeout: 256 seconds]
oddp has joined #ruby
Secret-Fire has quit [Remote host closed the connection]
Secret-Fire has joined #ruby
Secret-Fire has quit [Remote host closed the connection]
Secret-Fire has joined #ruby
mossplix has quit [Remote host closed the connection]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
rose_nd_ash has joined #ruby
rose_nd_ash has quit [Remote host closed the connection]
Phoebus has joined #ruby
Secret-Fire has quit [Remote host closed the connection]
Secret-Fire has joined #ruby
alfiemax has joined #ruby
yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
yxhuvud has joined #ruby
aurelius has quit [Remote host closed the connection]
rose_nd_ash has joined #ruby
aurelius has joined #ruby
ur5us has joined #ruby
Mia has quit [Read error: Connection reset by peer]
aesthe has joined #ruby
arahael1 has joined #ruby
Arahael has quit [Ping timeout: 260 seconds]
dionysus69 has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
alfiemax has quit [Remote host closed the connection]
markong has joined #ruby
Mia has joined #ruby
aesthe has quit [Quit: Leaving]
konsolebox has quit [Read error: Connection reset by peer]
alfiemax has joined #ruby
konsolebox has joined #ruby
rose_nd_ash has quit [Remote host closed the connection]
cd has quit [Quit: cd]
Mia has quit [Read error: Connection reset by peer]
chalkmonster has joined #ruby
ur5us has quit [Ping timeout: 244 seconds]
FastJack has quit [Ping timeout: 264 seconds]
bruce_lee has joined #ruby
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
leitz has joined #ruby
Rounin has joined #ruby
<leitz>
Pointers to a doc on how to use Net::HTTP.get? I'm hitting a certificate verify failure, which is expected. Trying to work around a hostname mismatch.
rose_nd_ash has joined #ruby
arahael1 is now known as Arahael
zacts has joined #ruby
aurelius has quit [Remote host closed the connection]
aurelius has joined #ruby
alfiemax has quit [Remote host closed the connection]
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
dualfade has joined #ruby
vondruch has quit [Ping timeout: 260 seconds]
vondruch_ is now known as vondruch
konsolebox has quit [Read error: Connection reset by peer]
konsolebox has joined #ruby
drincruz has joined #ruby
mossplix has quit [Remote host closed the connection]
oddp has joined #ruby
oddp has quit [Client Quit]
rose_nd_ash has quit [Remote host closed the connection]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
rose_nd_ash has joined #ruby
helpa has quit [Remote host closed the connection]
helpa has joined #ruby
noodle has quit [Ping timeout: 260 seconds]
noodle has joined #ruby
alfiemax has quit [Remote host closed the connection]
bamdad has quit [Remote host closed the connection]
bamdad has joined #ruby
markong has quit [Ping timeout: 256 seconds]
stryek has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
aurelius has quit []
helpa has quit [Remote host closed the connection]
helpa has joined #ruby
venmx has quit [Ping timeout: 265 seconds]
SeepingN has joined #ruby
rose_nd_ash has quit [Remote host closed the connection]
rose_nd_ash has joined #ruby
alfiemax has joined #ruby
TCZ has quit [Quit: Leaving]
rose_nd_ash has quit [Remote host closed the connection]
rose_nd_ash has joined #ruby
shansen has joined #ruby
imode has joined #ruby
lucasb has joined #ruby
mossplix has joined #ruby
<leitz>
Any maths wizards able to double check my expression? To get an "Improved by X%": percentate_improved = ( new - old) / ( old / 100.0)
gitter1234 has joined #ruby
imode has quit [Ping timeout: 264 seconds]
jacksop has joined #ruby
howdoi has joined #ruby
zacts has quit [Quit: WeeChat 2.8]
<adam12>
leitz: I use something like this: (new - old) / old.to_f * 100 unless old.zero?
<adam12>
leitz: I'm not sure if that's equivalent for you tho. There is percent change and percent difference.
mistergibson has joined #ruby
mossplix has quit [Remote host closed the connection]
MadLamb has joined #ruby
baojg has quit [Remote host closed the connection]
rose_nd_ash has quit [Remote host closed the connection]
<MadLamb>
I'm struggling with this problem for 2 days already. I have two rails active record models (Posts and Attachments) and I index some of the posts properties on solr with sunspot. As part of this solr document, I also include the attachments association, which I declare in the Posts model. Because the way the code works when binding those attachments t ther with the Posts, this attachment list is not being indexed when the model record is created
<MadLamb>
for the first time. It works as expected when I edit and save again. I was trying to force rails to run the index again by calling Posts.save!, but no matter how many times I do that, it doesn't help. Any idea?
rose_nd_ash has joined #ruby
rose_nd_ash has quit [Remote host closed the connection]
<adam12>
MadLamb: You have a hook defined in your model to call Sunspot?
<MadLamb>
adam12, i'm using the "searchable"
alfiemax has quit [Remote host closed the connection]
rose_nd_ash has joined #ruby
<MadLamb>
adam12, I do attachments.map and convert that to a string, which I stored in a string field with multiple => true
<adam12>
MadLamb: You have a sunspot.yml file?
<MadLamb>
yes I do, but I am running sunsport with docker
<MadLamb>
I mean solr*
<adam12>
MadLamb: what are the values for auto_index_callback and auto_remove_callback
<MadLamb>
auto_index_callback: after_commit
<MadLamb>
the remove is not present
baojg has joined #ruby
<MadLamb>
I added this to test, wasnt originally there
<adam12>
MadLamb: Do you have anything about "auto_index"?
baojg has quit [Remote host closed the connection]
<adam12>
I think it's set to true by default but just curious.
<MadLamb>
adam12, in sunspot.yml? no. its just the production env with solr and auto_index_callback keys. Inside solr I have log_level, path and solr_home. That is all.
<adam12>
MadLamb: In your model. searchable(auto_index: ??) or anything
<MadLamb>
adam12, yeah I think so. I tried to set that to true in the searchable, but no difference
baojg has joined #ruby
<MadLamb>
tried that already, also checked the code, it seems to only make a difference if you set to false
<MadLamb>
the thing is, the way those things are getting updated in my app, probably fucks with it
mossplix has joined #ruby
<MadLamb>
the attachments record is created before the psots
<MadLamb>
posts*
<adam12>
MadLamb: Can you crank up logging and see if the after_commit hook is running?
<MadLamb>
and then later on they get "connected"
<adam12>
Oh. I think I see the problem.
<adam12>
err, your issue. I thought it wasn't running at all.
<MadLamb>
yeah I think its running. It does work when I update
<MadLamb>
I hacked around it and forced a second save on update
<MadLamb>
but I think the main issue is that by the time the index runs, the model is not updated in memory yet
<MadLamb>
(the association)
<MadLamb>
it makes the change directly on the attachments model
FastJack has joined #ruby
<MadLamb>
instead of going through the posts
<MadLamb>
(and in this case it cant I think, because they are not connected yet)
<adam12>
MadLamb: I wonder if you add a `touch` to the relationship on attachments back to the post.
<MadLamb>
I even tried to do Posts.find and Posts.save to force a second index
<MadLamb>
but no idea why it doesnt work
baojg has quit [Remote host closed the connection]
<MadLamb>
idk how active record works behind the scenes but maybe if I find a model that is already in memory it doesnt actually make the search
<adam12>
apotheon: Some of the practices look familiar tho? I'm using substitutes in many places and I'm enjoying it. Some of the other ones are interesting.
konsolebox has joined #ruby
konsolebox has quit [Read error: Connection reset by peer]
teclator has quit [Ping timeout: 240 seconds]
lucasb has quit [Quit: Connection closed for inactivity]
rose_nd_ash has quit [Remote host closed the connection]
vondruch_ has joined #ruby
cthulchu_ has quit [Read error: Connection reset by peer]
cthulchu_ has joined #ruby
vondruch has quit [Ping timeout: 265 seconds]
vondruch_ is now known as vondruch
linuus[m] has quit [Ping timeout: 244 seconds]
finn[m] has quit [Ping timeout: 244 seconds]
jottr has quit [Quit: WeeChat 2.9]
ruurd has quit [Quit: bye folks]
zapata has quit [Ping timeout: 246 seconds]
zapata has joined #ruby
troulouliou_div2 has quit [Ping timeout: 246 seconds]
chalkmonster has quit [Quit: WeeChat 2.9]
dnadev2 has joined #ruby
troulouliou_div2 has joined #ruby
cd has joined #ruby
ritalinona has joined #ruby
linuus[m] has joined #ruby
alfiemax has quit [Ping timeout: 256 seconds]
finn[m] has joined #ruby
troulouliou_div2 has quit [Ping timeout: 265 seconds]
Phoebus has quit [Quit: Connection closed for inactivity]
zapata has quit [Ping timeout: 246 seconds]
<havenwood>
sapphyrus: hi
<havenwood>
oops
chalkmonster has joined #ruby
dionysus69 has quit [Ping timeout: 240 seconds]
chalkmonster has quit [Client Quit]
konsolebox has quit [Read error: Connection reset by peer]
leitz has quit [Quit: Leaving]
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
troulouliou_div2 has joined #ruby
<dnadev2>
can anyone help me figure out the best approach to DRY up code that shares a method between two classes that uses an instance var in the shared method? here is the set up: https://dpaste.org/dETz
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
_aeris_ has joined #ruby
konsolebox has joined #ruby
_aeris has quit [Ping timeout: 240 seconds]
<ritalinona>
dnadev2: you could inherit from a third class that has all the same code
cnsvc has joined #ruby
<dnadev2>
ritalinona, and if i do that -- with the parent have access to that @instance var i set in the child? Child < Parent
<dnadev2>
s/with/will
<phaul>
I would use mixin prly in this case.
<phaul>
also I would expose the instance var as reader that the mixin can use. ( instance var would work, but acess via method feels better somehow. like comparable does it with <=>
mossplix has quit [Remote host closed the connection]
Rudd0 has joined #ruby
mossplix has joined #ruby
arzWZM has quit [Ping timeout: 265 seconds]
arzWZM has joined #ruby
kristian_on_linu has quit [Quit: No Ping reply in 180 seconds.]
<phaul>
dnadev2: you are on the right path with the Bakery module, but there is some confusion about the current self in the classes. At class level self would be the class, so @user outside of instance method definition in for example BreadWorker would be an instance variable of the class itself - not the instance of it..
kristian_on_linu has joined #ruby
SeepingN has joined #ruby
Secret-Fire has quit [Remote host closed the connection]
<phaul>
class X; @foo; end; @foo is an instance variable stored in the Class object called X. class X; def bar; @foo; end; end; here it's different @foo is an instance variable stored in the object you get by instantiating X with calling X.new
skape has quit [Quit: Connection closed for inactivity]
<dnadev2>
yesss, this is making an insane amount of sense :) thank you phaul and havenwood!
Secret-Fire has joined #ruby
* dnadev2
still needs to learn how to assess situations to determine mixin vs inheritance situations
BSaboia has quit [Quit: This computer has gone to sleep]
Secret-Fire has quit [Remote host closed the connection]
<phaul>
my two pence. real class inheritance is only a choice if the classes make sense in the domain as such. The parent and child classes are all real things in the domain, that you want to instantiate, and Liskov is respected. If you just want to code dry, go with modules