Activity Graph

Page 1 of 8 | Next »


[04:03:50] ule: Quit: WeeChat 2.2
[04:20:31] ule: has joined #RubyOnRails
[04:20:31] ule: has joined #ruby


[14:50:50] ule: Hey guys, what is the best way to write raw queries AND sanitize parameters using Rails?
[14:51:29] ule: Ideally, I'm looking for somehting that does something like this: Model.connection.execute("my raw query WHERE foo = ?", foo)
[14:51:40] ule: But looks like it is not an option


[14:05:22] ule: What are you guys using to document APIs in 2019?
[14:05:31] ule: What are you guys using to document APIs in 2019?
[14:06:22] ule: Apiary? Swagger?
[14:06:28] ule: Apiary? Swagger?


[19:13:35] ule: The same way if we do: a = nil || 'foo', how would you do: a = [] || 'foo' ?
[19:14:13] ule: Assiming that sometimes [] is actually populated, and in this case, it shouldn't assume the default value 'foo'
[19:16:47] ule: nvm, just did a ternary if with conditional to solve the issue here


[19:13:05] ule: duleja: I have some complex queries that I just call Arel
[19:13:51] ule: duleja: When I can, I usually take advantage of Rails cache wrapping this raw sql query under Rails.cache do
[19:14:08] ule: This way, I still have cache the same way as using ActiveRecord
[19:14:28] ule: so I'd say yes, it can scale
[19:15:00] ule: The only disadvantage is that if you decide to move your project to a different database, you're gonna need to rewrite that
[19:15:35] ule: duleja: just curious, why would you do that?
[19:16:22] ule: duleja: Rails handles well that. The garbage collector will clean that on its on internal logic
[19:17:07] ule: duleja: it make sense, but if you call the same query multiple times using raw query, the complexity will be on each call. Using activerecord will at some level cache that
[19:17:25] ule: duleja: you can use .select to get only fields you want
[19:17:51] ule: duleja: 300 clients hitting the same endpoint for example
[19:18:32] ule: duleja: Rails has a connection pool
[19:19:13] ule: duleja: you can cache it manually if you want. Rails.cache
[19:19:33] ule: then it returns the response from your Redis for example instead of hit the database all the time
[19:19:59] ule: duleja: I might be wrong, but Rails caches queries on its on
[19:21:04] ule: duleja: let me ask you the most important question
[19:21:32] ule: duleja: Are you serving your app for a high number of users where you need to optimize queries at this level?
[19:22:05] ule: If yes, then I agree to cache and start using different strategies
[19:22:30] ule: but if not, premature optimization can hurt your team and your development
[19:22:45] ule: duleja: thats what I've been doing
[19:23:17] ule: duleja: I'm actually on MySQL and Redshift
[19:23:36] ule: yeah, wherever
[19:23:41] ule: same thing :P
[19:24:23] ule: but if you bypass your db caching with Redis, you're aliviating your DB and Redis is like laughting because it handles heavy load really well
[19:25:24] ule: duleja: I'd say that .execute will execute something that you loaded like prepare statement
[19:25:35] ule: vs .execute_query where you pass the query right there
[19:25:48] ule: does that make sense?
[19:26:18] ule: Let me take a look on docs here, but this is what make sense for me
[19:26:39] ule: I remember using prepare statements before and remember this .execute
[19:26:48] ule: It was a terrible idea btw
[19:27:11] ule: the mysql adaptor doesn't like to hold .prepare too much time. MySQL was throughing random crazy errors for 1 month
[19:27:28] ule: then I figure out it was a commit using .prepare, doing more logic between
[19:27:47] ule: found out that using prepare must get values and release from memory as fastest as you can
[19:28:05] ule: anyways, good learning
[19:28:13] ule: duleja: just curious, what is your load today?
[19:28:30] ule: Are you running servers in parallel? Whats your db size?
[19:29:04] ule: duleja: c'mon, I asked you before if you need premature optimiation right now
[19:29:55] ule: the reason I ask is beccause if you have more people in your dev team, using raw queries too much can make things difficuld. Lets say a new developer 6 month for now wants implement a feature that he can get just manipulating the Rails object
[19:30:14] ule: if he needs to change query or deal with raw query this for me is like code smells
[19:31:27] ule: But yeah, I use myself only when I need complex queries, multiple joins etc. Most of them all cached
[19:32:03] ule: btw, you can create a new strucutre in your rails like: "app/queries/crazy_query.rb
[19:32:43] ule: for hashes you can use "presenters" like Gitlab does
[19:33:52] ule: duleja: for example, inside your class, you just override the .to_h method, that gets your object and converts to a hash
[19:34:11] ule: CrazyQuery.new(wherever).to_h
[19:34:38] ule: duleja: not sure if pluck works the same way as .select
[19:34:58] ule: .select for jusr does the query like: SELECT username FROM users
[19:35:15] ule: where .pluck might do SELECT * FROM users and filters out from the Object returned
[19:35:32] ule: but I'm not 100% sure on that, you might need to run some .to_sql to debug that
[19:36:36] ule: for example: User.all.to_sql
[19:36:46] ule: for example: User.all.pluck(:email).to_sql
[19:37:00] ule: User.all.select(:email).to_sql
[19:37:04] ule: Might be the same thing
[19:37:08] ule: but I'm not sure
[19:38:30] ule: duleja: which language/framework were you working before?
[19:40:29] ule: duleja: no, it is just intersting this interest for optimization without need
[19:40:45] ule: I thought you came from a background like Embedded Systems, C, etc
[19:41:19] ule: I feel like if you don't need to worry about performance, you need to chill and be happy with AR
[19:41:47] ule: caching queries here and there, but overall, take advantage of AR
[19:42:20] ule: duleja: OK, why do you need performance? What is the bottleneck?
[19:43:05] ule: How many requests per second? How much memory per server? Are you using Unicorn, Puma? How many workers per server on cgi deamon?
[19:43:34] ule: duleja: sometimes you just need to setup mysql correct. mysqltunner.pl is a great tool
[19:45:21] ule: From someone that leads a Rails team, I see too much pre-optimization as a bad practice. You can be expending time developting new features for the product instead of worrying about something that is not even an issue right now
[19:46:01] ule: I'd recommend using Rails cache instead of raw queries if you don't need complex queries


[16:12:08] ule: Quit: WeeChat 2.2
[19:20:26] ule: has joined #ruby
[19:20:31] ule: has joined #RubyOnRails


[02:25:52] ule: baweaver: cool
[02:26:05] ule: Great article


[15:12:09] ule: Kind of Railsish question. How would you architecture your system if you need to convert data from one format to another one? In my case, I need to convert Rails User Objects to a specific crazy json format (SCIM schema)
[15:12:20] ule: Would you use somehting like DTO (data transfer objects)?
[15:12:30] ule: Maybe a different pattern like: builder?
[15:13:13] ule: bring the system architecture that lives in your brain to here and please help this little programmer


[18:14:46] ule: FrankDW2: before running update, try: e.errors or e.valid?
[18:22:34] ule: FrankDW2: :)


[14:23:46] ule: _sfiguser: move away of it :P


[00:37:37] ule: Any news of Rails 6?
[00:38:02] ule: someone told me it might get released on the RailsConf that is happening
[01:00:56] ule: Maybe there is someone from Rails core here in this chat?
[01:01:24] ule: Who knows..
[15:44:49] ule: havenwood: yeah I know, I'm wondering when the final one is going to be out
[19:13:57] ule: Do you guys know if there is a method that transform this: {a:1}to: { [{a:1},{a:1},{a:1}] }
[19:14:28] ule: I'm not sure how to search by that. Clone? Multiply? Duplicate hash?
[19:16:37] ule: phaul: dammit. The simples solution ever that I didn't even think about it. :P
[19:16:40] ule: Thank you very much!
[19:29:58] ule: phaul: I'm working here to generate some dummy data through an API. If a specific parameter is set, the response will return some dummy data
[19:30:10] ule: That will be really handy
[19:33:22] ule: phaul: For most of the endpoints, I'm gonna generate seeds with dummy data.. but for some endpoints that basically returns data from external data sources, I'm intercepting and "injecting" this dummy response
[19:33:46] ule: First time doing this kind of stuff. I'm kind of following my guts so far.. :/
[19:34:08] ule: But always with something telling me that this is a kind of code smell :D


[21:14:37] ule: miah: neat


[01:53:23] ule: ActionController::RoutingError (No route matches [GET] "/fonts/gijgo-material.ttf")
[01:53:42] ule: Does anybody knows how do I solve this? I already added this ttf inside app/assets/fonts
[01:53:56] ule: Already added assets.precompile to read *.ttf
[01:54:06] ule: Also already added assets.paths to read fonts/
[01:54:15] ule: I have no more clue
[02:23:49] ule: nvm, managed to put it working overriding it with asset_url()


[17:54:11] ule: Anyone here using Kubernetes with our lovelly Rails?
[18:12:11] ule: randohinn: What do you mean by "make a DB"? Create a table in your Database and not necessary have a model class for it?
[18:12:28] ule: ActiveRecord::Base.connection.execute("CREATE TABLE foo ... ")
[18:12:52] ule: Well, if you don't want models, why do you need migrations?
[18:13:49] ule: randohinn: you can add that command I paste inside a migration
[18:14:07] ule: basically, you can a RAW mysql query directly
[18:14:29] ule: randohinn: is that an Temp Table? Why don't you want a model related?
[18:16:16] ule: lol I did something similar here, but it was to avoid iterating over thousans of lines of an CSV
[18:17:04] ule: randohinn: here, we basically dump the CSV file into a temporary table, then we trigger workers + Sidekiq using a gem that does batch processing for sidekiq to digest that entire list in parallel
[18:18:22] ule: randohinn: I saw a tweet from UncleBob this morning critizising XML. He said it is a terrible thing
[18:18:52] ule: sorry for my typos, just woke up and English is still catching up on my brain
[18:36:37] ule: alnk: sorry? Link for what?
[18:36:59] ule: It was just a comment. I don't have the procedure written down


[16:28:53] ule: You can just setup the network on your VM on a way that it gets an valid ip address. This way you can just call your VM directly


[00:57:57] ule: Morning? Japan Timezone?
[01:02:30] ule: Australia?
[01:03:26] ule: Radar: Is it Tuesday for you already? Thats cool eh, I'm chatting with someone in the future
[01:03:55] ule: Lucky guy. It is dark, monday and cold over here
[01:04:35] ule: Radar: what have you been you cooding in the past days?
[01:08:54] ule: Cool, one of the features I really like is that kind of guard statement on the method signature.
[01:09:05] ule: def foo if x > y
[01:09:33] ule: kind of weird to think but I give my thumbs up for this on Elixir
[01:10:20] ule: I spoke with some guys that actually see this as an overhead saying that if we use this all the time, we're gonna have a lot of method, one per each conditions


[17:46:02] ule: has joined #ruby
[17:46:09] ule: has joined #RubyOnRails


[12:14:23] ule: Ping timeout: 250 seconds


[19:07:38] ule: has joined #ruby
[19:07:45] ule: has joined #RubyOnRails


[17:44:57] ule: Ping timeout: 252 seconds


[02:31:39] ule: havenwood: thank you


[20:24:21] ule: Do you guys, can I use merge() here:
[20:24:23] ule: {:filters=>[{"name"=>"foo", "value"=>"123"}, {"name"=>"Company", "value"=>"17"}, {"name"=>"bar", "value"=>"123"}], :foo_id=>"434"}
[20:25:07] ule: To override that {"name"=>"Company", "value"=>"17"} with {"name"=>"Company", "value"=>"111"} ?
[20:26:06] ule: or the best way is just iterating on each element of that hash and compare if name == Company && value == 17?


[13:33:15] ule: Quit: WeeChat 1.9.1
[15:13:31] ule: has joined #RubyOnRails
[15:13:31] ule: has joined #ruby


[18:23:41] ule: I did a while ago.. I was planning to help out in the project but never got a chance
[18:23:47] ule: phatcat: are you planning to?
[18:28:18] ule: I didn't run the project in Prod mode. As far as I remember there is a Docker somewhere


[01:19:20] ule: *.net *.split
[13:31:52] ule: has joined #RubyOnRails
[13:31:57] ule: has joined #ruby
[19:25:41] ule: ivanskie: sure, whats up?
[19:26:23] ule: ivanskie: which region are you connecting to? No problems here
[19:27:10] ule: ivanskie: https://status.aws.amazon.com
[19:27:57] ule: ivanskie: Something is wrong there
[19:28:08] ule: ivanskie: 30/40 seconds sounds too much
[19:28:56] ule: ivanskie: try calling aws via aws-cli and see if it is fast
[19:29:06] ule: same method, describeInstance
[19:36:14] ule: ivanskie: looks like you're calling "eb.describe_environments" 2 times inside your before block


[16:29:05] ule: has joined #ruby
[16:29:26] ule: Hey guys. I'm using OpenStruct to dimanically convert a hash like: ':foo => "bar"' into something like: MyOpenStruct.foo
[16:30:02] ule: My question is how would you convert nested hashes as well? When I do OpenStruct.new(my_hash) it only converts the top level keys
[16:30:28] ule: apeiros: (: thanks
[16:30:52] ule: I'm creating a wrapper to the SpaceX Api
[16:32:15] ule: apeiros: I'm wondering if there is a kind of ruby magic oneline method that digs into all nested hash keys "Dynamically"
[16:32:32] ule: RedNifre: it will display launches data, it is really cool
[16:32:50] ule: RedNifre: https://api.spacexdata.com/v2/launches/latest
[16:33:25] ule: Ohh. I know Hashie gem. I didn't know I could do that with it
[16:33:34] ule: apeiros: thanks
[16:33:51] ule: Criten: exactly what I need. Thanks!
[16:33:57] ule: Criten: so cool eh?
[16:36:14] ule: Hi new, I'm ule
[16:40:28] ule: man this Hashie gem has a lot of cool stuff
[16:41:00] ule: wtf is that? a chatbot?
[16:45:05] ule: Hashie::Mash.new(foo = {a: 123, b: { c: 456 } }).b.c
[16:45:16] ule: a w e s o m e
[17:29:02] ule: oh yeah my bad, I don't need to "foo ="
[17:29:32] ule: al2o3-cr: just using json lib eh, nice
[17:30:05] ule: RedNifre: I use vim as well. Love it


[00:01:33] ule: I'm working to translate something here. What do you understand by this term: "probably will have to crank their libraries"
[00:58:30] ule: Zarthus: thanks!


[00:52:45] ule: Hey guys, what would you use to paginate a hash? Lets say I have a list with 100 items and want to paginate this into 5 groups
[00:53:04] ule: Not sure if there is a magic enumerable method that does this out of the box
[00:53:25] ule: a kind of group_by(n elements)
[01:22:47] ule: havenwood: thanks!


[00:07:03] ule: *.net *.split
[00:15:26] ule: has joined #RubyOnRails
[00:15:41] ule: has joined #ruby


[15:28:54] ule: Hey guys, I just finish upgrading rails from 4.2.10 to 5.0.7. I'm wondering if I should upgrade to 5.1 or 5.2 now. I just want to understand better what these numbers means
[15:29:25] ule: Is odd versions a kind of short version just for tests? Any specific rule for Long Term Support versions based on these numbers?
[15:31:22] ule: This channel is usually more active then Rails. If you don't mind asking here, do you know what's the difference between 5.0.7, 5.1.6, 5.2.0 in terms of stability? Is the Long Terms Support related with these numbers? I just upgraded from 4.2.10 to 5.0.7, so now I'm trying to figure out if it worth upgrading to 5.1 or 5.2. I'm not sure which version makes more sense though. Any thoughts?
[15:31:45] ule: sorry in advance, I know this is a #ruby channel, but anyways.. :)
[15:36:01] ule: havenwood: I just read here: http://guides.rubyonrails.org/maintenance_policy.html
[15:36:16] ule: that there is only security fixes to 5.2 and 5.1
[15:36:30] ule: havenwood: ok, thank you very much
[15:37:24] ule: got the answer from there, thanks guys!


[12:55:43] ule: What's the best way to track something wrong if you have a chain of callbacks over multiple models?
[14:43:20] ule: s2013: Maybe it is your browser cache?
[14:43:35] ule: s2013: try: https://www.ssllabs.com/ssltest/
[14:46:16] ule: Yes it does, your main certificate must be configured accordingly
[14:46:35] ule: Sometimes, wildcard certificate, sometimes one extra entry when you generate the whole thing
[14:47:49] ule: I'm not sure about Heroku though. Are you using something provided by them or you create your own certificate?
[14:48:35] ule: Oh I see.
[14:48:50] ule: 25 bucks month? thats expensive
[14:49:07] ule: Let me see details of this plan.. I'm curious now
[14:51:25] ule: that make sense
[15:22:03] ule: Milenials are switching to JavaScript


[02:19:23] ule: Ping timeout: 240 seconds
[17:36:44] ule: has joined #ruby
[17:36:44] ule: Changing host
[17:36:52] ule: has joined #RubyOnRails


[01:56:44] ule: Hey guys. After I upgraded to Rails 5, if I pass an empty value like this it doesn't show up on my params insite my controller:
[01:57:12] ule: post :update, params: { foo: []}
[01:57:23] ule: If I pass: post :update, params: { foo: ['']} # it works
[01:57:33] ule: or post :update, params: { foo: []}, as: :json # it also works
[01:57:58] ule: so my question is: How to make that pass without as: :json? Just passing foo: []?


[17:41:21] ule: chouhoulis: try restarting your console
[17:41:38] ule: looks like you created after your console session was initialized
[17:47:40] ule: xco: I don't believe you can use unless that way
[17:48:28] ule: xco: try replacing for a normal IF block with - unless "something"
[17:49:04] ule: drale2k_: oh yeah, just add a "before_action
[17:49:15] ule: in your controller while you load that car
[17:50:10] ule: for me, in that case, make sense inside your album controller. You have a method like: "def load_car" right?
[17:50:18] ule: or "load_album" ?
[17:50:52] ule: xco: I would just removing that "unless" from that inline sintax
[17:51:27] ule: drale2k_: oh I see, so in that case, you need to intercept before Rails tries to load that car
[17:51:46] ule: I'm not familiar with what this "default rest" is doing though
[17:55:22] ule: Oh so, in that case, you got a controller with default actions


[02:46:58] ule: *.net *.split
[02:47:47] ule: has joined #RubyOnRails
[02:48:04] ule: has joined #ruby
[02:50:12] ule: *.net *.split
[02:51:07] ule: has joined #RubyOnRails
[02:51:08] ule: has joined #ruby


[18:26:17] ule: has joined #ruby
[18:26:19] ule: has joined #RubyOnRails