« Back to channel list

#RubyOnRails - 22 March 2019

« Back 1 day Forward 1 day »
[00:01:11] alexeev: has joined #RubyOnRails
[00:15:56] orbyt_: has joined #RubyOnRails
[00:17:23] jottr: has joined #RubyOnRails
[00:22:28] Tempesta: has joined #RubyOnRails
[00:33:20] jottr: has joined #RubyOnRails
[00:38:35] xco: has joined #RubyOnRails
[00:45:32] kvda: has joined #RubyOnRails
[00:49:08] jottr: has joined #RubyOnRails
[01:01:25] aseibert: has joined #RubyOnRails
[01:04:00] sevenseacat: has joined #RubyOnRails
[01:04:58] jottr: has joined #RubyOnRails
[01:06:35] alexeev: has joined #RubyOnRails
[01:11:39] alexeev: yoshie902a: well, address hasn't association `profile`. So you can't join it. For what you need join it?
[01:12:04] bambanx: has joined #RubyOnRails
[01:20:51] jottr: has joined #RubyOnRails
[01:24:39] krawchyk: has joined #RubyOnRails
[01:33:14] hammer065: has joined #RubyOnRails
[01:36:42] jottr: has joined #RubyOnRails
[01:39:19] hnanon: has joined #RubyOnRails
[01:42:26] kvda: has joined #RubyOnRails
[01:44:47] xco: has joined #RubyOnRails
[01:52:44] jottr: has joined #RubyOnRails
[01:53:46] hammer065: has joined #RubyOnRails
[02:07:56] kvda: has joined #RubyOnRails
[02:22:21] jottr: has joined #RubyOnRails
[02:31:36] kvda: has joined #RubyOnRails
[02:38:26] jottr: has joined #RubyOnRails
[02:45:41] lily___: has joined #RubyOnRails
[02:54:17] jottr: has joined #RubyOnRails
[03:05:33] Saukk: has joined #RubyOnRails
[03:10:11] jottr: has joined #RubyOnRails
[03:26:06] jottr: has joined #RubyOnRails
[03:29:43] phaul: has joined #RubyOnRails
[03:31:40] s00pcan_: has joined #RubyOnRails
[03:36:03] agent_white: has joined #RubyOnRails
[03:42:00] jottr: has joined #RubyOnRails
[03:58:13] jottr: has joined #RubyOnRails
[03:59:16] mangold: has joined #RubyOnRails
[04:01:28] s00pcan: has joined #RubyOnRails
[04:05:01] bambanx: has joined #RubyOnRails
[04:05:02] bambanxx: has joined #RubyOnRails
[04:10:22] braincrash: has joined #RubyOnRails
[04:13:27] akosednar: has joined #RubyOnRails
[04:14:00] jottr: has joined #RubyOnRails
[04:29:51] jottr: has joined #RubyOnRails
[04:31:47] epochwolf: has joined #RubyOnRails
[04:32:59] coffeejunk: has joined #RubyOnRails
[04:32:59] pro777: has joined #RubyOnRails
[04:33:11] AgelZ: has joined #RubyOnRails
[04:34:07] AgelZ: I am currently working on project and i need to do some testing eaither cucumber or unit testing can somoene help me?
[04:36:05] JJonah: has joined #RubyOnRails
[04:36:05] Nuck: has joined #RubyOnRails
[04:36:25] AgelZ: Anyone got expierince with testing?
[04:39:34] jtperreault: has joined #RubyOnRails
[04:45:49] jottr: has joined #RubyOnRails
[04:48:16] hahuang65: AgelZ: what's your question?
[04:49:00] AgelZ: I need to do some testing on code and i dont know where to start
[04:49:04] AgelZ: gems wont install
[04:55:02] hahuang65: AgelZ: what do you mean gems won'
[04:55:40] hahuang65: post us a pastie of your problem, instead of speaking in generalizations. We can't really help if we don't understand what the problem is
[04:58:47] AgelZ: theres no copy pasting tbh
[04:58:56] AgelZ: i have a code and i need to test it using unit testing
[04:59:08] AgelZ: its twitter code
[05:01:34] jottr: has joined #RubyOnRails
[05:01:57] alexeev: has joined #RubyOnRails
[05:02:43] alexeev: yoshie902a: you can make a dirty hack: create association to `profile` for addresses where addressable_type == 'Profile' and join it. But anyway it is bad way.
[05:05:40] hahuang65: AgelZ: i have no idea how to help you if you won't give me details... What is the problem?
[05:08:13] AgelZ: want me to sent the code here?
[05:16:56] AgelZ: @hauang65 if you can 1:1 that would be great
[05:31:00] jottr: has joined #RubyOnRails
[05:45:31] dionysus69: has joined #RubyOnRails
[05:46:49] jottr: has joined #RubyOnRails
[05:47:24] alexeev: has joined #RubyOnRails
[05:49:34] srinidhi: has joined #RubyOnRails
[05:51:59] hahuang65: AgelZ: put your code in a pastebin dude.
[05:53:13] AgelZ: https://ghostbin.com/paste/q2dr5
[05:53:24] AgelZ: there are a lot of more .erb file thoe
[05:53:59] alexeev_: has joined #RubyOnRails
[05:55:52] hahuang65: AgelZ: okay, last time I'm gonna say this. Please tell me what the issue is. I don't want to read through your entire project codebase. Tell me what the issue is so I can figure out where to start.
[05:58:24] AgelZ: i need to do a unit test
[05:58:26] AgelZ: for this programm
[05:59:01] hahuang65: AgelZ: okay, so I understand your goal. You want to write tests for this code.
[05:59:13] hahuang65: AgelZ: now, what is the problem? Why can't you write the tests?
[05:59:43] AgelZ: i dont know how
[06:00:00] AgelZ: i ve been going all night
[06:00:10] hahuang65: AgelZ: what did you try?
[06:00:50] AgelZ: i try using the vim command as people suggested
[06:00:53] AgelZ: didnt work
[06:01:07] AgelZ: tryed opening new ruby files
[06:01:31] AgelZ: but i just dont know how to test it. Its something completly new for me
[06:01:44] hahuang65: AgelZ: what vim command did people suggest
[06:01:54] AgelZ: just vim and start typing
[06:04:41] hahuang65: AgelZ: have you written any tests for any code before?
[06:05:26] hahuang65: AgelZ: have you written code before?
[06:05:59] AgelZ: its basicly a team uni project
[06:06:13] AgelZ: and one of my members didnt do his task
[06:06:22] AgelZ: i was given too at last momment
[06:06:32] hahuang65: AgelZ: have you written Sinatra code before?
[06:08:01] hahuang65: AgelZ: I'm going to send you a link, because no one here is really going to have time to basically walk you thru your assignment
[06:08:11] hahuang65: AgelZ: but hopefully this link will be helpful in getting you started on testing
[06:08:13] hahuang65: http://sinatrarb.com/testing.html
[06:08:29] AgelZ: thanks i ll see what i can do
[06:09:02] hahuang65: AgelZ: I will HIGHLY recommend, ignoring your project code for now... Walk thru that testing tutorial, understand how things work, then apply it to your project
[06:09:08] hahuang65: AgelZ: good luck
[06:09:26] hahuang65: I'm signing out for tonight, but I will be around tomorrow, if you have some specific questions
[06:12:33] AgelZ: thanks for evrything
[06:14:26] hahuang65: AgelZ: sure. Sinatra might be a little confusing at first too, so you might want to search for "Ruby Test Driven Development Tutorial" as well just to get familiar with testing Ruby
[06:16:41] conta: has joined #RubyOnRails
[06:39:43] reber: has joined #RubyOnRails
[06:49:18] dionysus69: has joined #RubyOnRails
[06:51:50] defsdoor_: has joined #RubyOnRails
[06:54:55] alexeev: has joined #RubyOnRails
[06:56:34] mangold: has joined #RubyOnRails
[07:08:15] za1b1tsu: has joined #RubyOnRails
[07:08:50] alexeev: has joined #RubyOnRails
[07:18:02] za1b1tsu: has joined #RubyOnRails
[07:25:58] beanHolez: has joined #RubyOnRails
[07:27:56] alexeev: has joined #RubyOnRails
[07:29:44] hahuang6-: has joined #RubyOnRails
[07:46:57] Dbugger: has joined #RubyOnRails
[08:10:41] jottr: has joined #RubyOnRails
[08:51:52] mikecmpbll: has joined #RubyOnRails
[09:47:58] srinidhi: has joined #RubyOnRails
[09:50:08] agent_white: has joined #RubyOnRails
[09:51:39] nemesit|znc: has joined #RubyOnRails
[10:05:03] hightower2: has joined #RubyOnRails
[10:14:24] mangold: has joined #RubyOnRails
[11:00:49] JJonah: has joined #RubyOnRails
[11:11:08] reber: has joined #RubyOnRails
[11:15:45] sevenseacat: has joined #RubyOnRails
[11:16:09] Sylario: has joined #RubyOnRails
[11:20:06] guyzmo: hi 👋 I got a weird bug with ActiveRecord sum. I got `class Foo; has_many :bars; end` and `class Bar; belongs_to :foo; end`. Bar has an integer attribute `Bar.total`. Within Foo, if I do `foo.bars.count` I got 4 elements, and each has a `total` value of 20. If I do `Foo.bars.map(&:total).sum` I get 80. If I do `Foo.bars.sum(:total)` I get 20, but I'd expect both to valuate to 80. Am I misunderstanding
[11:20:08] guyzmo: something on how `.sum` works?
[11:21:15] sevenseacat: have you overridden the total method on whatever Bar is? the first is a Ruby method call, the second is doing an SQL sum
[11:21:46] guyzmo: no, I did not
[11:22:49] guyzmo: I even tried giving an SQL string as parameter to sum(): `Foo.bars.sum('foos.total')` and it still gives me 20
[11:23:13] guyzmo: is there a way to inspect the sum method, like I could do a to_sql with an associationproxy?
[11:23:21] sevenseacat: can you use some real names instead of foos and bars? and show the code you're using?
[11:25:19] guyzmo: well, if I do that, that would be close to be talking about foos and bars, because I'd be removing a lot of unnecessary code to focus on the issue
[11:26:04] guyzmo: but definitely I do believe this is PEBCAK, my fault… I'm just struggling to find out what I did wrong
[11:27:16] conta: has joined #RubyOnRails
[11:27:50] guyzmo: ah! Just read some SO answer : /And it will call sum in the SQL database, so the result gets influenced by the parameters of the query, e.g. groups, joins, etc./
[11:28:27] guyzmo: indeed, I left that bars is not a straight path to Bar, I the query is a SELECT DISTINCT + joins
[11:28:48] guyzmo: (it's a has_many with condition)
[11:29:24] mmoll: has left #RubyOnRails: ("WeeChat 2.4")
[11:30:29] guyzmo: ok, looks like it's that
[11:30:59] guyzmo: if I do Foo.where(id: Foo.bars.ids).sum(:total) I get the correct sum
[11:32:33] guyzmo: so either I run a subselect or I do it in plain ruby
[11:33:38] guyzmo: (or I make the query more complex to correctly handle the aggregate)
[11:33:56] guyzmo: sevenseacat - thank you for reading me :)
[11:34:23] syndikate: Does it matter if we memoize a variable in a controller? Wouldn't that controller be destroyed once the request is done and the memoization leaves no benefit?
[11:35:35] guyzmo: syndikate - that depends on how long you want your memoization to live
[11:35:47] guyzmo: syndikate - and what you want to use it for
[11:36:27] guyzmo: syndikate - if you want to memoize for the life span of the controller instance (up until the request is served, AFAICT), you can do it as an attribute
[11:37:03] syndikate: guyzmo, this is the scenario https://hastebin.com/weqidujepi.rb
[11:37:46] guyzmo: if you want to memoize it for the life span of your whole process (given you have no threads and no multiprocess enabled), you can do it using a class member, but I would advise against that
[11:38:11] guyzmo: if you want to memoize it for a long time, just use Rails.cache
[11:38:20] syndikate: Its just for the request life span, there is no use after it
[11:38:26] syndikate: I have the current code like this https://hastebin.com/ifaqucewis.rb
[11:38:33] syndikate: But I don't understand why we need to do that
[11:38:47] guyzmo: you mean the set_book call?
[11:38:54] syndikate: @book variable
[11:39:24] syndikate: Memoising current_user inside APplicationController makes sense because lots of controllers would be inherited (right?)
[11:39:26] guyzmo: because BookController's methods are idempotent, meaning that they don't rely on state
[11:40:09] guyzmo: to give them state, you need to link them to the model, thus the @book = Book.find call you do at the start of a method
[11:40:32] guyzmo: then the model you want is contextualized to the query you give to the controller
[11:41:23] syndikate: Agreed, but my question is memoizing that @book variable makes any sense? Because the controller object is done once the request is finished, and no other class inherits/uses it
[11:41:59] guyzmo: what you pasted is not memoizing
[11:42:04] guyzmo: it's just setting an attribute
[11:42:27] guyzmo: you could replace the before_action with a call to Book.find at the start of your method
[11:42:36] guyzmo: that's *exactly* the same thing
[11:43:12] syndikate: Yes, check this paste -> https://hastebin.com/ifaqucewis.rb
[11:43:16] syndikate: I passed two different ones
[11:43:19] guyzmo: the before_action is just some syntactic sugar to avoid repeating yourself at the start of every action method where you would translate params[:id] into a book
[11:43:35] syndikate: The paste I shared above, isn't that memoization?
[11:44:10] guyzmo: @book will *always* be nil when you call http://yourhost/book/<id> before entering set_book
[11:44:36] guyzmo: each time you call a controller method, your BookController instance is a new one
[11:44:43] syndikate: Yes, so setting @book ||= Book.find(x) is useless, right?
[11:45:01] guyzmo: you just need to do @book = Book.find(params[:id])
[11:45:27] syndikate: Yup, that's what I wanted to confirm. My current code bas has this style for such controllers and I wanted to remove them, not that they are harm they are just useless
[11:45:28] guyzmo: to translate the id query paramater into a book instance, so you can work on the model in your controller method
[11:46:05] guyzmo: if the code has been written by someone not stupid (which should be expected)
[11:46:12] guyzmo: maybe the ||= has been done on purpose
[11:46:37] guyzmo: and maybe there's another before_action that might set @book before the before_action you have which might instanciate @book before
[11:46:44] guyzmo: (maybe in a superclass)
[11:46:55] syndikate: No, none. I checked all those.
[11:47:02] syndikate: This is a fresh module, fresh controller
[11:47:08] guyzmo: actually, this is one of the reasons I avoid the 'callbacks'
[11:47:20] guyzmo: because it's always a source of surprises
[11:48:01] guyzmo: I prefer to repeat myself, because I believe the rule of least expectation surpasses the DRY rule
[11:48:25] syndikate: Totally agree, but I need to use it here
[11:48:49] syndikate: I just wanted to get that ||= out of the way, I wanted to make sure my assumption is correct
[11:49:21] mangold: has joined #RubyOnRails
[11:56:10] MrCrackPotBuilde: has joined #RubyOnRails
[12:06:56] bvdw6: has joined #RubyOnRails
[12:07:09] hhzza_: has joined #RubyOnRails
[12:07:12] netz: has joined #RubyOnRails
[12:07:14] fowlduck_: has joined #RubyOnRails
[12:10:51] guyz: has joined #RubyOnRails
[12:12:21] matthewd_: has joined #RubyOnRails
[12:13:09] russt_: has joined #RubyOnRails
[12:13:57] TheMoonMaster: has joined #RubyOnRails
[12:18:29] ss942: Any cool videos with tips and tricks in Rails? (something ~1h long would be great)
[12:20:52] Ergo: has joined #RubyOnRails
[12:21:15] LightStalker: has joined #RubyOnRails
[12:22:22] mcr: has joined #RubyOnRails
[12:34:04] ss942: has left #RubyOnRails: ()
[12:36:08] mikecmpbll: has joined #RubyOnRails
[12:48:43] xco: has joined #RubyOnRails
[12:50:08] Saukk: has joined #RubyOnRails
[12:59:28] wolfravenous: has joined #RubyOnRails
[13:00:32] jottr: has joined #RubyOnRails
[13:09:12] jottr_: has joined #RubyOnRails
[13:18:51] dionysus69: any plans to replace sass-rails gem with sassc-rails in new application, since sass-rails is depracated in 6 days as the warning says
[13:19:09] dionysus69: rails 6 beta 3 still has sass-rails
[13:30:57] xco: has joined #RubyOnRails
[13:40:42] wickdbloodfart: has joined #RubyOnRails
[13:45:23] apparition: has joined #RubyOnRails
[14:01:13] xco: has joined #RubyOnRails
[14:03:28] wickedbloodfart: has joined #RubyOnRails
[14:08:17] alexeev: has joined #RubyOnRails
[14:09:49] alexeev: has joined #RubyOnRails
[14:11:07] alexeev_: has joined #RubyOnRails
[14:21:13] borodin: has joined #RubyOnRails
[14:22:15] hnanon: has joined #RubyOnRails
[14:24:30] RedRedD: has joined #RubyOnRails
[14:43:45] agent_white: has joined #RubyOnRails
[14:45:41] duderonomy: has joined #RubyOnRails
[14:49:00] rascencio: has joined #RubyOnRails
[14:59:45] gambl0r3: has joined #RubyOnRails
[15:02:44] context: has joined #RubyOnRails
[15:03:19] catbusters: has joined #RubyOnRails
[15:03:33] context: so.. how do i change the encoding of an uploaded file? i have Encoding.default_ext/int both set to UTF-8 and i did config.encoding = 'utf-8' but ActionDispatch::Http::UploadedFile is still being opened as ASCII
[15:10:43] wolfravenous: has joined #RubyOnRails
[15:16:58] context: cause going params[:file].tempfile.set_encoding('utf-8') doesnt seem right...
[15:18:00] hnanon: has joined #RubyOnRails
[15:19:29] lato: has joined #RubyOnRails
[15:19:32] orbyt_: has joined #RubyOnRails
[15:40:59] lato: has joined #RubyOnRails
[15:45:14] mangold: has joined #RubyOnRails
[15:45:56] lato: has joined #RubyOnRails
[15:46:33] xco: has joined #RubyOnRails
[15:52:44] lato: has joined #RubyOnRails
[16:11:37] hnanon_: has joined #RubyOnRails
[16:18:42] mangold: has joined #RubyOnRails
[16:31:47] alexeev: has joined #RubyOnRails
[16:34:13] orbyt_: has joined #RubyOnRails
[16:37:02] wolfravenous: has joined #RubyOnRails
[16:37:29] bambanx: has joined #RubyOnRails
[16:37:49] conta: has joined #RubyOnRails
[17:01:57] s00pcan: has joined #RubyOnRails
[17:08:26] DTZUZO: has joined #RubyOnRails
[17:10:05] mangold: has joined #RubyOnRails
[17:12:51] s00pcan: has joined #RubyOnRails
[17:22:20] Dbugger: has joined #RubyOnRails
[17:25:54] orbyt_: has joined #RubyOnRails
[17:26:38] neozor: has joined #RubyOnRails
[17:29:07] Scriptonaut: has joined #RubyOnRails
[17:31:13] KeyJoo: has joined #RubyOnRails
[17:50:11] hnanon: has joined #RubyOnRails
[17:54:02] uks: has joined #RubyOnRails
[17:54:03] uksio: has joined #RubyOnRails
[17:56:53] s00pcan: has joined #RubyOnRails
[17:58:21] Saukk: has joined #RubyOnRails
[18:00:36] mikecmpbll: has joined #RubyOnRails
[18:04:06] bambanx: has joined #RubyOnRails
[18:19:10] gambl0r3: has joined #RubyOnRails
[18:44:36] hnanon_: has joined #RubyOnRails
[19:03:42] Scriptonaut: Hey all, I setup a staging server for my rails 5 app. It uses nginx + unicorn. The staging environment is currently identical to the production env file (I haven't actually made a production yet). When I hit the server, I get: ActionView::Template::Error (The asset "application.css" is not present in the assett pipeline). I want nginx to serve up my assets, not the asset pipeline.
[19:03:58] Scriptonaut: Here is my env file staging.rb: https://gist.github.com/robins35/b7340bc428f2873849ffa8c96f39e2b4 (Is there anything obviously wrong in there?)
[19:04:25] Scriptonaut: There is no $RAILS_SERVE_STATIC_FILES env var set by the way
[19:06:39] Scriptonaut: I ran: rails assets:precompile, and my public/assets dir is filled with application-#{some_hash}.css, application-#{some_hash}.js, and then a .gz version of both of those
[19:10:38] ellcs: has joined #RubyOnRails
[19:34:13] MrCrackPotBuilde: has joined #RubyOnRails
[19:35:02] rascencio: has joined #RubyOnRails
[19:41:45] cousine: has joined #RubyOnRails
[19:41:58] cousine: has left #RubyOnRails: ()
[19:44:24] bambanx: has joined #RubyOnRails
[19:58:34] uks: has joined #RubyOnRails
[20:04:49] rascencio: has joined #RubyOnRails
[20:10:32] cousine: has joined #RubyOnRails
[20:11:19] cousine: has joined #RubyOnRails
[20:22:31] orbyt_: has joined #RubyOnRails
[20:37:53] cousine: has joined #RubyOnRails
[20:44:51] wolfravenous: has joined #RubyOnRails
[20:48:33] bambanx: has joined #RubyOnRails
[20:48:54] hightower2: has joined #RubyOnRails
[21:09:14] andywww: has joined #RubyOnRails
[21:09:35] gambl0r3: has joined #RubyOnRails
[21:24:15] gambl0r3: has joined #RubyOnRails
[21:32:18] ellcs: has joined #RubyOnRails
[21:42:41] ellcs: has joined #RubyOnRails
[21:48:31] bambanxx: has joined #RubyOnRails
[21:58:03] xco_: has joined #RubyOnRails
[22:12:15] gambl0r3: has joined #RubyOnRails
[22:12:22] Fernando-Basso: has joined #RubyOnRails
[22:13:27] orbyt_: has joined #RubyOnRails
[22:33:06] alexeev: has joined #RubyOnRails
[22:48:38] FLeiXiuS: has joined #RubyOnRails
[22:48:51] FLeiXiuS: Does rails auto create controlller methods like, create, read, etc? Also - when an action is blank, does rails automatically set an instance var for the model? So User would populate @user by default?
[22:49:01] FLeiXiuS: I know that it does - im just curious as to the documentation for it.
[22:52:36] Scriptonaut: has left #RubyOnRails: ()
[22:58:41] tdy: has joined #RubyOnRails
[22:58:55] xco_: has joined #RubyOnRails
[22:59:17] tfitts: has joined #RubyOnRails
[23:09:09] dviola: has joined #RubyOnRails
[23:23:16] rascencio: has joined #RubyOnRails