<ZAJDAN>
in same way as in Ruby I can use CGI in Rails?
deepreds1 has quit [Ping timeout: 248 seconds]
deepreds1 has joined #ruby
<havenwood>
ZAJDAN: Yeah, Rails is just Ruby.
<ZAJDAN>
ok..thank YOu
deepreds1 has quit [Ping timeout: 244 seconds]
<ZAJDAN>
how I can extract first parameter 'dir' ? ...this come from AJAX: Parameters: {"dir"=>"6_BUGGY/", "onlyFolders"=>"false", "onlyFiles"=>"false", "multiSelect"=>"false"}
deepreds1 has joined #ruby
<ZAJDAN>
I am trying: if cgi.has_key?('dir') puts "is there" else dir = cgi.params["dir"].to_s end
<ZAJDAN>
is possibe via CGI process aforesaid hash?
absolutejam1 has joined #ruby
mayurvpatil has joined #ruby
ellcs has joined #ruby
queip has quit [Ping timeout: 245 seconds]
emptyfl4sk has joined #ruby
Freshnuts has quit [Quit: Leaving]
queip has joined #ruby
kyrylo has joined #ruby
emptyfl4sk has quit [Ping timeout: 245 seconds]
thunderbirdtr has quit [Quit: ZNC 1.7.3 - https://znc.in]
<NL3limin4t0r>
ZAJDAN: Why do you need to use CGI in RoR? The framework already handles incomming requests parameters and offers them through the `params` method. You can simply do `params.include?(:dir)` or `params.include?('dir')`
<ZAJDAN>
NL3: ye...right now I already tested it
<NL3limin4t0r>
You could also use `has_key?` or `key?` instead of `include?`
<ZAJDAN>
dir = (params[:dir])
<NL3limin4t0r>
But RoR stuff should be in the #RubyOnRails channel.
emptyfl4sk has quit [Ping timeout: 272 seconds]
DarthGandalf has quit [Ping timeout: 248 seconds]
jacksop has quit []
queip has quit [Ping timeout: 245 seconds]
queip has joined #ruby
Dr_MDMA_MD has quit [Quit: Connection closed for inactivity]
ryouba has joined #ruby
<ryouba>
hi
<ryouba>
is there something like Hash#||+= or if not, what's the most concise way of expressing that?
<ryouba>
i.e. `foo ||= Hash.new; foo[:blah] ||+= 1`
<ryouba>
i actually confused myself for a second when i wrote it
* ryouba
scratches head and wonders why head loves complexity so much
<balo>
if you don't want to write `if !err` and you use rails, you can try `if err.blank?` to keep it nice
<ryouba>
no sir, no rails here. did that for much longer than was good for my mental health. finally got rid of it some years ago. just plain ruby scripts now, and my life has become so much better since :-D
chens has joined #ruby
<ryouba>
i do usually monkey patch #blank? into basically everything, though, because i find it helpful.
pwnd_nsfw has joined #ruby
queip has quit [Ping timeout: 248 seconds]
ananth99 has quit [Quit: Connection closed for inactivity]
queip has joined #ruby
<balo>
yeah, it should be part of the stdlib i think, implemented natively. there is a reason why fast_blank exists
AlHafoudh has quit [Ping timeout: 272 seconds]
mayurvpatil has quit [Quit: This computer has gone to sleep]
dbugger has joined #ruby
_dbugger has quit [Ping timeout: 264 seconds]
absolutejam1 has joined #ruby
mayurvpatil has joined #ruby
_dbugger has joined #ruby
<ryouba>
!Hash.new == Hash.new(0)
mikecmpbll has joined #ruby
<ryouba>
hmm, okay, that's *not* how to use the bot
<ryouba>
balo: seconded, and thirded, and fourthed.
dbugger has quit [Ping timeout: 264 seconds]
sarink has quit [Remote host closed the connection]
<ryouba>
balo: can't find it rn, but there's some mailing list post by matz where he argues against making it part of stdlib. i only remember thinking that his arguments weren't strong enough to supersede the simple "a lot of people would use this all the time without any negative side effect" argument.
AlHafoudh has joined #ruby
sarink has joined #ruby
nomenkun has quit [Quit: Leaving...]
absolutejam1 has quit [Ping timeout: 272 seconds]
<ryouba>
phaul: you're right, it would at the very least be ambiguous.
<ryouba>
balo: yes, a little more digestible as an evening lecture
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
absolutejam1 has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
absolutejam1 has quit [Ping timeout: 258 seconds]
emptyfl4sk has joined #ruby
<ZAJDAN>
how to append a string to variable? means something like has PHP: somevariable = " string"; somevariable .= "next string";
<ZAJDAN>
I foundit .concat is the right way
emptyfl4sk has quit [Ping timeout: 244 seconds]
<NL3limin4t0r>
ryouba: In your code the hash might or might not exist, in this case you can simply add the default after creation. `@cols.send(col).stats.default = 0`
<NL3limin4t0r>
ZAJDAN: You can use `"string 1" + "string 2"` to combine strings. This can also be used with assignment operators like `+=` eg. `string += "new addition"`
<NL3limin4t0r>
Or if you don't mind mutating the original string: `string << "new addition"`
<havenwood>
Interesting to see Tokaido back alive with 2.6 support!
sarink has quit [Remote host closed the connection]
brool has joined #ruby
irc_chat has joined #ruby
megamos has joined #ruby
conta has joined #ruby
<NL3limin4t0r>
snigelfarfar_: It depends on what you expect, both #reverse and #chomp don't mutate the array, but create a new copy. Since #each_char doesn't do anything with the returned value you could say `.reverse.chomp(g)` are called in void context.
queip has quit [Ping timeout: 246 seconds]
englishm has quit [Excess Flood]
englishm has joined #ruby
Swyper has quit [Remote host closed the connection]
<NL3limin4t0r>
&>> test = 'test'; test.each_char { |char| test.reverse!.chomp!(char) }
<NL3limin4t0r>
Keep in mind that iterating over an collection and modifying it at the same time might yield unexpected results.
Swyper has joined #ruby
ellcs has quit [Ping timeout: 245 seconds]
<NL3limin4t0r>
In this case it takes the `t` and `e`, removes both from the string. After that there are only 2 characters left, since #each_char iterated 2 times it thinks it is done. So the `e` and `s` stay behind.
<NL3limin4t0r>
&>> test = 'test'; test.dup.each_char { |char| test.reverse!.chomp!(char) }
mayurvpatil has quit [Quit: This computer has gone to sleep]
aupadhye has quit [Quit: Leaving]
<pinky>
stupid question, when you have a class inside another class, can you access the class instance variables from the outer class?
AJA4350 has quit [Ping timeout: 258 seconds]
Nicmavr has quit [Read error: Connection reset by peer]
<havenwood>
pinky: You can only get at instance variables from within the instance where they were defined. Nested classes don't get any special exposure to instance variables.
<pinky>
ah ok is there a common pattern used for that?
Nicmavr has joined #ruby
<havenwood>
pinky: Show the code?
<pinky>
i guess when i instantiate the inner class from the outer one i could pass self into it or something?
<pinky>
hm thats hard to do
<havenwood>
pinky: Why are there two classes? Do they share state?
<pinky>
the inner ones are data containers
<pinky>
so the outer one has an instance of faraday interacting with an api
<havenwood>
Do they need to be nested? Why do they share state? Do they share concerns?
<pinky>
hm they don't really share state
<havenwood>
I'd suggest making it simpler, if you can. It'd help if we could see the code.
<pinky>
a module can just have constants i guess?
<havenwood>
The simplest thing that can possibly work is a good starting point.
<havenwood>
Then refactor, only if it's an improvement.
kyrylo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood>
pinky: Yes, a module can have constants.
<havenwood>
pinky: Public by default, or private.
AJA4350 has joined #ruby
<pinky>
so a constant wouldn't help me, the object i want available from the contained classes is a faraday object
<havenwood>
pinky: Why can't you assign a constant to that Faraday client?
<havenwood>
Is it open source?
absolutejam1 has joined #ruby
<pinky>
i assume the variable i use to instantiate the faraday client can't be a constant
<ruby[bot]>
pinky: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
sandstrom has quit [Quit: My computer has gone to sleep.]
<havenwood>
tf2ftw: An aside, but should line 3 be?: 'Accept-Charset' => 'utf-8' }.freeze
<tf2ftw>
Indeed (hat tip)
jefffrails35 has quit [Quit: Leaving]
<havenwood>
tf2ftw: Yeah, I don't see any middleware. Maybe VCR middleware is involved? I've not run into this.
sarink has quit [Ping timeout: 245 seconds]
<tf2ftw>
That's what I was thinking too. However, when when I bundle console this (its a gem) and run it from there I still get the warning.. I'll keep digging. Thanks havenwood
kurko_ has joined #ruby
sarink has joined #ruby
<tf2ftw>
Confirmed VCR is not loaded in bundle console.. hmm
kyrylo has joined #ruby
<havenwood>
tf2ftw: I might try to step up the stack with byebug.
<tf2ftw>
I am using pry so I guess that's my next step. I haven't used it beyond dropping into specific points so this will be a new learning experience :)
kyrylo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
yokel has quit [Remote host closed the connection]
yokel has joined #ruby
jacobnollette_ has joined #ruby
greypack has quit [Ping timeout: 248 seconds]
jacobnollette_ has quit [Client Quit]
greypack has joined #ruby
ajamieli` has joined #ruby
<greypack>
hallo
ajamielittle has quit [Ping timeout: 252 seconds]
sarink has quit [Remote host closed the connection]
sarink has joined #ruby
<havenwood>
greypack: hi
snigelfarfar_ has quit [Ping timeout: 268 seconds]
millerti has joined #ruby
queip has quit [Ping timeout: 244 seconds]
code_zombie has joined #ruby
NikhilSinghal has quit [Ping timeout: 252 seconds]
NikhilSinghal has joined #ruby
queip has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.5]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
absolutejam2 has joined #ruby
suukim has quit [Quit: Konversation terminated!]
absolutejam1 has quit [Ping timeout: 248 seconds]
AJA4351 has joined #ruby
sandstrom has joined #ruby
sarink has quit [Remote host closed the connection]
AJA4350 has quit [Ping timeout: 268 seconds]
AJA4351 is now known as AJA4350
sarink has joined #ruby
sarink has quit [Remote host closed the connection]
matheusm1reira has joined #ruby
matheusmoreira has quit [Ping timeout: 258 seconds]
sandstrom has quit [Quit: My computer has gone to sleep.]
<pinky>
i wonder if theres a way to look in the namespace for class definitions and be able to find the ones that are a subclass of a particular one :)
<pinky>
i'm in an outer class and trying to dynamically instantiate one defined inside it
<pinky>
oh i think it works with the actual name of the class not self
<phaul>
You can look at ObjectSpace.each_object it even takes a superclass (optionally)
<pinky>
nice thanks .. i think i figured this out, pretty sweet :)
<pinky>
ruby has some nice stuff python doesn't have :P
<phaul>
it's surprising sometimes how much is "just" code rather than special syntax
catbusters has quit [Quit: Connection closed for inactivity]
reber has quit [Remote host closed the connection]
absolutejam3 has joined #ruby
absolutejam2 has quit [Ping timeout: 268 seconds]
chalkmonster has joined #ruby
powerbit has quit [Quit: Going offline, see ya! (www.adiirc.com)]
Fernando-Basso has joined #ruby
oetjenj has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
emptyfl4sk has quit [Ping timeout: 272 seconds]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.5]
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
oetjenj has joined #ruby
oetjenj has quit [Client Quit]
<brool>
i have a modular sinatra app i'm executing via rackup, so '/ttt' will run an instance of my sinatra app, in order that that app can treat '/ttt' as if it were root '/'. my problem is that, on the view i'm serving for "get '/'" in that app (which client-side looks like 'localhost/ttt') i am running javascript and calling fetch('/mlem'), which *would* work if the URI i ask to fetch() was requesting
<brool>
"localhost/ttt/mlem" but it *actually* requests "localhost/mlem"
<brool>
i've been reading about how fetch() works and people are saying it is supposed to treat URIs as relative paths, except in my case it's not and i assume that's because it's being served by sinatra which is responding to "get '/'" even though rackup is running that app in response to a request for "/ttt"
jordanm has quit [Remote host closed the connection]
jordanm has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
matheusm1reira is now known as matheusmoreira
brett-soric has left #ruby [#ruby]
lepepe has quit [Remote host closed the connection]
AJA4351 has joined #ruby
yokel has quit [Remote host closed the connection]
AJA4350 has quit [Ping timeout: 244 seconds]
AJA4351 is now known as AJA4350
lepepe_ has joined #ruby
yokel has joined #ruby
cisco has quit [Ping timeout: 248 seconds]
emptyfl4sk has joined #ruby
lepepe_ has quit [Ping timeout: 244 seconds]
snigelfarfar_ has joined #ruby
jordanm has quit [Remote host closed the connection]